1 | <?php |
||
10 | class BaseApiController extends Controller |
||
11 | { |
||
12 | /** |
||
13 | * The config implementation. |
||
14 | * |
||
15 | * @var array |
||
16 | */ |
||
17 | protected $config; |
||
18 | |||
19 | /** |
||
20 | * The relations implementation. |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $relations; |
||
25 | |||
26 | /** |
||
27 | * The repo implementation. |
||
28 | * |
||
29 | * @var object |
||
30 | */ |
||
31 | protected $repo; |
||
32 | |||
33 | /** |
||
34 | * Init new object. |
||
35 | * |
||
36 | * @param mixed $repo |
||
37 | * @param CoreConfig $config |
||
38 | * @param string $modelResource |
||
39 | * @return void |
||
|
|||
40 | */ |
||
41 | public function __construct($repo, $config, $modelResource) |
||
57 | |||
58 | /** |
||
59 | * Fetch all records with relations from storage. |
||
60 | * |
||
61 | * @param Request $request |
||
62 | * @return \Illuminate\Http\Response |
||
63 | */ |
||
64 | public function index(Request $request) |
||
68 | |||
69 | /** |
||
70 | * Fetch the single object with relations from storage. |
||
71 | * |
||
72 | * @param integer $id Id of the requested model. |
||
73 | * @return \Illuminate\Http\Response |
||
74 | */ |
||
75 | public function find($id) |
||
79 | |||
80 | /** |
||
81 | * Delete by the given id from storage. |
||
82 | * |
||
83 | * @param integer $id Id of the deleted model. |
||
84 | * @return \Illuminate\Http\Response |
||
85 | */ |
||
86 | public function delete($id) |
||
90 | |||
91 | /** |
||
92 | * Return the deleted models in pages based on the given conditions. |
||
93 | * |
||
94 | * @param Request $request |
||
95 | * @return \Illuminate\Http\Response |
||
96 | */ |
||
97 | public function deleted(Request $request) |
||
101 | |||
102 | /** |
||
103 | * Restore the deleted model. |
||
104 | * |
||
105 | * @param integer $id Id of the restored model. |
||
106 | * @return \Illuminate\Http\Response |
||
107 | */ |
||
108 | public function restore($id) |
||
112 | |||
113 | /** |
||
114 | * Check if the logged in user can do the given permission. |
||
115 | * |
||
116 | * @param string $permission |
||
117 | * @return void |
||
118 | */ |
||
119 | private function checkPermission($permission) |
||
141 | |||
142 | /** |
||
143 | * Set sessions based on the given headers in the request. |
||
144 | * |
||
145 | * @return void |
||
146 | */ |
||
147 | private function setSessions() |
||
174 | |||
175 | /** |
||
176 | * Set relation based on the called api. |
||
177 | * |
||
178 | * @param string $route |
||
179 | * @return void |
||
180 | */ |
||
181 | private function setRelations($route) |
||
187 | |||
188 | /** |
||
189 | * Update the logged in user locale and time zone. |
||
190 | * |
||
191 | * @param object $user |
||
192 | * @return void |
||
193 | */ |
||
194 | private function updateLocaleAndTimezone($user) |
||
213 | } |
||
214 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.