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 == auth()->user()->company()->id; }); $data['companies'] = $companies->reject(function ($company){ return $company->id == auth()->user()->company()->id; }); return $data; } }