mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
39 lines
811 B
PHP
39 lines
811 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\ViewComposers;
|
||
|
|
||
|
use App\Utils\Traits\UserSessionAttributes;
|
||
|
use Illuminate\View\View;
|
||
|
|
||
|
class HeaderComposer
|
||
|
{
|
||
|
use UserSessionAttributes;
|
||
|
|
||
|
/**
|
||
|
* Bind data to the view.
|
||
|
*
|
||
|
* @param View $view
|
||
|
* @return void
|
||
|
*/
|
||
|
public function compose(View $view)
|
||
|
{
|
||
|
$view->with('header', $this->headerData());
|
||
|
}
|
||
|
|
||
|
private function headerData()
|
||
|
{
|
||
|
//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;
|
||
|
}
|
||
|
|
||
|
}
|