private function passData($id = null) { $HQAddresses = new \App\Models\Addresses(); $HQPhones = new \App\Models\Phones(); $company = new \App\Models\Companies(); $ultimateParentCompany = new \App\Models\Companies(); if (!is_null($id)) { $company = Companies::findOrNew($id); $mediaContacts = $company->mediaContacts()->get(); $attachments = $company->attachments()->get(); $ultimateParentCompany = $company->ultimateParent()->get(); } else { if (!Session::has('MediaContacts')) { Session::set('MediaContacts', $company->mediaContacts()->get()); } if (!Session::has('CompanyAttachments')) { Session::set('CompanyAttachments', $company->attachments()->get()); } $mediaContacts = Session::get('MediaContacts'); $attachments = Session::get("CompanyAttachments"); } $eSize = EmployeeSize::all()->toArray(); $gProfile = GrowthProfile::where('id_Growth_Profile', '>', 1)->get()->toArray(); $oship = Ownership::all()->toArray(); $rStage = RevenueStage::where('id_Revenue_Stage', '>', 1)->get()->toArray(); $cType = CompanyType::all()->toArray(); $csType = CompanySubType::all()->toArray(); $uParent = Companies::where("Deleted", "=", NULL)->get()->sortBy('Company_Full_Name')->toArray(); $products = $company->products()->whereNull("Deleted"); foreach ($products->get() as $product) { $productFocusTypeList[$product->id_Product] = []; $productTypeList = []; foreach ($product->focusSubType()->get() as $productSubType) { $productTypeList[0] = $productSubType->Product_Focus_Sub_Type; $productTypeListValues = ProductFocusType::where('id_Product_Focus_Type', '=', $productSubType->id_Product_Focus_Type)->get()->first(); $productTypeList[1] = $productTypeListValues->Product_Focus_Type; $productFocusTypeList[$product->id_Product][] = $productTypeList; } } if ($company->headquaters()->get()->count()) { $HQAddresses = Addresses::findOrNew($company->headquaters()->get()->first()->AddressId); } if ($company->headquaters()->get()->count() && $company->headquaters()->get()->first()->PhoneId) { $HQPhones = Phones::findOrNew($company->headquaters()->get()->first()->PhoneId); } foreach ($eSize as $emSize) { $employeeSize[$emSize["id_Employee_Size"]] = $emSize["Employee_Size"]; } foreach ($gProfile as $gwProfile) { $growthProfile[$gwProfile["id_Growth_Profile"]] = $gwProfile["Growth_Profile"]; } foreach ($oship as $owship) { $ownership[$owship["id_Ownership"]] = $owship["Ownership"]; } foreach ($rStage as $revStage) { $revenueStage[$revStage["id_Revenue_Stage"]] = $revStage["Revenue_Stage"]; } foreach ($cType as $coType) { $companyType[$coType["id_Company_Type"]] = $coType["Company_Type"]; } foreach ($csType as $coSuType) { $companySubType[$coSuType["id_Company_Sub_Type"]] = $coSuType["Company_Sub_Type_Name"]; } foreach ($uParent as $ulParent) { $ultimateParent[$ulParent["id_Company"]] = $ulParent["Company_Full_Name"]; } $country = Country::getListCountries(); return compact("employeeSize", "growthProfile", "productFocusTypeList", "ownership", "revenueStage", "companyType", "companySubType", "company", "ultimateParent", "mediaContacts", "country", "HQAddresses", "HQPhones", "products", "attachments", "ultimateParentCompany"); }