2018-11-26 05:15:08 +01:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2020-01-07 01:13:47 +01:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
2018-11-26 05:15:08 +01:00
|
|
|
|
|
|
|
namespace App\Http\ViewComposers;
|
|
|
|
|
|
|
|
use Illuminate\View\View;
|
|
|
|
|
2019-01-27 00:22:57 +01:00
|
|
|
/**
|
|
|
|
* Class HeaderComposer
|
|
|
|
* @package App\Http\ViewComposers
|
|
|
|
*/
|
2018-11-26 05:15:08 +01:00
|
|
|
class HeaderComposer
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bind data to the view.
|
|
|
|
*
|
|
|
|
* @param View $view
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function compose(View $view)
|
|
|
|
{
|
|
|
|
$view->with('header', $this->headerData());
|
|
|
|
}
|
|
|
|
|
2019-01-27 00:22:57 +01:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-11-26 05:15:08 +01:00
|
|
|
private function headerData()
|
|
|
|
{
|
2019-12-30 22:59:12 +01:00
|
|
|
if (!auth()->user()) {
|
2018-11-27 07:59:16 +01:00
|
|
|
return [];
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-05-22 05:52:38 +02:00
|
|
|
|
2019-05-22 05:53:11 +02:00
|
|
|
$companies = auth()->user()->companies;
|
2018-11-26 05:15:08 +01:00
|
|
|
|
2019-05-22 05:52:38 +02:00
|
|
|
//companies
|
|
|
|
$data['current_company'] = $companies->first();
|
|
|
|
$data['companies'] = $companies;
|
2019-12-30 22:59:12 +01:00
|
|
|
/*
|
|
|
|
$data['current_company'] = $companies->first(function ($company){
|
|
|
|
return $company->id == auth()->user()->company()->id;
|
|
|
|
});
|
2020-03-21 06:37:30 +01:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
$data['companies'] = $companies->reject(function ($company){
|
|
|
|
return $company->id == auth()->user()->company()->id;
|
|
|
|
});
|
|
|
|
*/
|
2018-11-26 05:15:08 +01:00
|
|
|
return $data;
|
|
|
|
}
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|