70 lines
1.7 KiB
PHP
Raw Normal View History

2017-09-14 22:21:00 +03:00
<?php
namespace App\Http\ViewComposers;
use Auth;
use App\Utilities\Updater;
use Illuminate\View\View;
2018-06-25 17:59:27 +03:00
use App\Traits\Modules as RemoteModules;
2017-09-14 22:21:00 +03:00
class Header
{
2018-06-25 17:59:27 +03:00
use RemoteModules;
2018-05-25 16:57:58 +03:00
2017-09-14 22:21:00 +03:00
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
2019-11-16 10:21:14 +03:00
$user = user();
2017-09-14 22:21:00 +03:00
$bills = [];
$invoices = [];
$notifications = 0;
$company = null;
// Get customer company
2019-11-16 17:38:48 +03:00
if ($user->can('read-client-portal')) {
$company = (object) [
2019-11-16 10:21:14 +03:00
'company_name' => setting('company.name'),
'company_email' => setting('company.email'),
'company_address' => setting('company.address'),
'company_logo' => setting('company.logo'),
2017-09-14 22:21:00 +03:00
];
}
$undereads = $user->unreadNotifications;
foreach ($undereads as $underead) {
$data = $underead->getAttribute('data');
switch ($underead->getAttribute('type')) {
case 'App\Notifications\Expense\Bill':
$bills[$data['bill_id']] = $data['amount'];
$notifications++;
break;
case 'App\Notifications\Income\Invoice':
$invoices[$data['invoice_id']] = $data['amount'];
$notifications++;
break;
}
}
$updates = count(Updater::all());
2018-06-25 17:59:27 +03:00
$this->loadSuggestions();
2018-05-25 16:57:58 +03:00
2017-09-14 22:21:00 +03:00
$view->with([
'user' => $user,
'notifications' => $notifications,
'bills' => $bills,
'invoices' => $invoices,
'company' => $company,
'updates' => $updates,
]);
}
}