2018-11-26 05:15:08 +01:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2022-04-27 05:20:41 +02:00
|
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-05-11 05:32:07 +02:00
|
|
|
*/
|
2018-11-26 05:15:08 +01:00
|
|
|
|
|
|
|
namespace App\Http\ViewComposers;
|
|
|
|
|
|
|
|
use Illuminate\View\View;
|
|
|
|
|
2019-01-27 00:22:57 +01:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Class HeaderComposer.
|
2019-01-27 00:22:57 +01:00
|
|
|
*/
|
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()
|
|
|
|
{
|
2020-09-06 11:38:10 +02:00
|
|
|
if (! auth()->user()) {
|
2018-11-27 07:59:16 +01:00
|
|
|
return [];
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2020-09-06 11:38:10 +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
|
|
|
}
|