Blame view

app/Http/Controllers/Modules/Tiles.php 2.6 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
  <?php
  
  namespace App\Http\Controllers\Modules;
  
  use App\Http\Controllers\Controller;
  use App\Traits\Modules;
  use App\Models\Module\Module;
  use Illuminate\Routing\Route;
  use Illuminate\Http\Request;
  
  class Tiles extends Controller
  {
      use Modules;
  
      /**
       * Show the form for viewing the specified resource.
       *
       * @param  $alias
       *
       * @return Response
       */
      public function categoryModules($alias)
      {
          $this->checkApiToken();
  
          $data = $this->getModulesByCategory($alias);
  
          $title = $data->category->name;
          $modules = $data->modules;
          $installed = Module::all()->pluck('status', 'alias')->toArray();
  
          return view('modules.tiles.index', compact('title', 'modules', 'installed'));
      }
  
      /**
       * Show the form for viewing the specified resource.
       *
       * @return Response
       */
      public function paidModules()
      {
          $this->checkApiToken();
  
          $title = trans('modules.top_paid');
          $modules = $this->getPaidModules();
          $installed = Module::all()->pluck('status', 'alias')->toArray();
  
          return view('modules.tiles.index', compact('title', 'modules', 'installed'));
      }
  
      /**
       * Show the form for viewing the specified resource.
       *
       * @return Response
       */
      public function newModules()
      {
          $this->checkApiToken();
  
          $title = trans('modules.new');
          $modules = $this->getNewModules();
          $installed = Module::all()->pluck('status', 'alias')->toArray();
  
          return view('modules.tiles.index', compact('title', 'modules', 'installed'));
      }
  
      /**
       * Show the form for viewing the specified resource.
       *
       * @return Response
       */
      public function freeModules()
      {
          $this->checkApiToken();
  
          $title = trans('modules.top_free');
          $modules = $this->getFreeModules();
          $installed = Module::all()->pluck('status', 'alias')->toArray();
  
          return view('modules.tiles.index', compact('title', 'modules', 'installed'));
      }
  
      /**
       * Show the form for viewing the specified resource.
       *
       * @return Response
       */
      public function searchModules(Request $request)
      {
          $this->checkApiToken();
  
          $keyword = $request['keyword'];
  
          $data = [
              'query' => [
                  'keyword' => $keyword,
              ]
          ];
  
          $title = trans('modules.search');
          $modules = $this->getSearchModules($data);
          $installed = Module::all()->pluck('status', 'alias')->toArray();
  
          return view('modules.tiles.index', compact('title', 'modules', 'keyword', 'installed'));
      }
  }