1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Http/ViewComposers/HeaderComposer.php

39 lines
811 B
PHP
Raw Normal View History

<?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;
}
}