Blame view

app/Http/ViewComposers/Modules.php 911 Bytes
b7c7a5f6   Alexey Boroda   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  <?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)
      {
          if (setting('general.api_token')) {
              $categories = Cache::remember('modules.categories', Date::now()->addHour(6), function () {
                  return collect($this->getCategories())->pluck('name', 'slug')
                      ->prepend(trans('general.all_type', ['type' => trans_choice('general.categories', 2)]), '');
              });
          } else {
              $categories = collect([
                  '' => trans('general.all_type', ['type' => trans_choice('general.categories', 2)]),
              ]);
          }
  
          $view->with(['categories' => $categories]);
      }
  }