with('header', $this->headerData()); } /** * @return array */ private function headerData() { if(!auth()->user()) return []; //companies $companies = auth()->user()->companies; $data['current_company'] = $companies->first(function ($company){ return $company->id == $this->getCurrentCompanyId(); }); $data['companies'] = $companies->reject(function ($company){ return $company->id == $this->getCurrentCompanyId(); }); return $data; } }