first commit
This commit is contained in:
26
app/Http/ViewComposers/All.php
Normal file
26
app/Http/ViewComposers/All.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\ViewComposers;
|
||||
|
||||
use App\Traits\DateTime;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class All
|
||||
{
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* Bind data to the view.
|
||||
*
|
||||
* @param View $view
|
||||
* @return void
|
||||
*/
|
||||
public function compose(View $view)
|
||||
{
|
||||
// Make sure it's installed
|
||||
if (env('DB_DATABASE', '') != '') {
|
||||
// Share date format
|
||||
$view->with(['date_format' => $this->getCompanyDateFormat()]);
|
||||
}
|
||||
}
|
||||
}
|
64
app/Http/ViewComposers/Header.php
Normal file
64
app/Http/ViewComposers/Header.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\ViewComposers;
|
||||
|
||||
use Auth;
|
||||
use App\Utilities\Updater;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class Header
|
||||
{
|
||||
/**
|
||||
* Bind data to the view.
|
||||
*
|
||||
* @param View $view
|
||||
* @return void
|
||||
*/
|
||||
public function compose(View $view)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$bills = [];
|
||||
$invoices = [];
|
||||
$notifications = 0;
|
||||
$company = null;
|
||||
|
||||
// Get customer company
|
||||
if ($user->customer()) {
|
||||
$company = (object)[
|
||||
'company_name' => setting('general.company_name'),
|
||||
'company_email' => setting('general.company_email'),
|
||||
'company_address' => setting('general.company_address'),
|
||||
'company_logo' => setting('general.company_logo'),
|
||||
];
|
||||
}
|
||||
|
||||
$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());
|
||||
|
||||
$view->with([
|
||||
'user' => $user,
|
||||
'notifications' => $notifications,
|
||||
'bills' => $bills,
|
||||
'invoices' => $invoices,
|
||||
'company' => $company,
|
||||
'updates' => $updates,
|
||||
]);
|
||||
}
|
||||
}
|
23
app/Http/ViewComposers/Index.php
Normal file
23
app/Http/ViewComposers/Index.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\ViewComposers;
|
||||
|
||||
use Illuminate\View\View;
|
||||
|
||||
class Index
|
||||
{
|
||||
/**
|
||||
* Bind data to the view.
|
||||
*
|
||||
* @param View $view
|
||||
* @return void
|
||||
*/
|
||||
public function compose(View $view)
|
||||
{
|
||||
$limits = ['10' => '10', '25' => '25', '50' => '50', '100' => '100'];
|
||||
|
||||
$years = ['2017' => '2017', '2016' => '2016', '2015' => '2015', '2014' => '2014'];
|
||||
|
||||
$view->with(['limits' => $limits, 'years' => $years]);
|
||||
}
|
||||
}
|
35
app/Http/ViewComposers/Menu.php
Normal file
35
app/Http/ViewComposers/Menu.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\ViewComposers;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\View\View;
|
||||
use anlutro\LaravelSettings\Facade as Settingg;
|
||||
|
||||
class Menu
|
||||
{
|
||||
/**
|
||||
* Bind data to the view.
|
||||
*
|
||||
* @param View $view
|
||||
* @return void
|
||||
*/
|
||||
public function compose(View $view)
|
||||
{
|
||||
$customer = null;
|
||||
$company_id = session('company_id');
|
||||
|
||||
// Get all companies
|
||||
$companies = Auth::user()->companies()->get()->sortBy('name');
|
||||
foreach ($companies as $com) {
|
||||
$com->setSettings();
|
||||
}
|
||||
|
||||
// Get customer
|
||||
if (Auth::user()->customer) {
|
||||
$customer = Auth::user();
|
||||
}
|
||||
|
||||
$view->with(['companies' => $companies, 'customer' => $customer]);
|
||||
}
|
||||
}
|
32
app/Http/ViewComposers/Modules.php
Normal file
32
app/Http/ViewComposers/Modules.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\ViewComposers;
|
||||
|
||||
use App\Models\Addon\Addon;
|
||||
use App\Traits\Modules as RemoteModules;
|
||||
use Cache;
|
||||
use Date;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class Modules
|
||||
{
|
||||
use RemoteModules;
|
||||
|
||||
/**
|
||||
* Bind data to the view.
|
||||
*
|
||||
* @param View $view
|
||||
* @return void
|
||||
*/
|
||||
public function compose(View $view)
|
||||
{
|
||||
if (setting('general.api_token')) {
|
||||
$categories = Cache::remember('modules.categories', Date::now()->addHour(6), function () {
|
||||
return collect($this->getCategories())->pluck('name', 'slug')
|
||||
->prepend(trans('categories.all'), '');
|
||||
});
|
||||
|
||||
$view->with(['categories' => $categories]);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user