akaunting/app/Http/ViewComposers/Modules.php

36 lines
936 B
PHP
Raw Normal View History

2017-09-14 19:21:00 +00:00
<?php
namespace App\Http\ViewComposers;
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)
{
2019-11-16 07:21:14 +00:00
if (setting('apps.api_key')) {
2018-12-19 12:36:40 +00:00
$categories = Cache::remember('modules.categories.' . language()->getShortCode(), Date::now()->addHour(6), function () {
2017-09-14 19:21:00 +00:00
return collect($this->getCategories())->pluck('name', 'slug')
2017-09-27 18:58:43 +00:00
->prepend(trans('general.all_type', ['type' => trans_choice('general.categories', 2)]), '');
2017-09-14 19:21:00 +00:00
});
2017-11-01 23:00:54 +00:00
} else {
$categories = collect([
'' => trans('general.all_type', ['type' => trans_choice('general.categories', 2)]),
]);
2017-09-14 19:21:00 +00:00
}
2017-11-01 23:00:54 +00:00
$view->with(['categories' => $categories]);
2017-09-14 19:21:00 +00:00
}
}