@@ -8,16 +8,16 @@ |
||
8 | 8 | class ReportsController extends BaseApiController |
9 | 9 | { |
10 | 10 | /** |
11 | - * The name of the model that is used by the base api controller |
|
12 | - * to preform actions like (add, edit ... etc). |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $model = 'reports'; |
|
11 | + * The name of the model that is used by the base api controller |
|
12 | + * to preform actions like (add, edit ... etc). |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $model = 'reports'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * List of all route actions that the base api controller |
|
19 | - * will skip permissions check for them. |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected $skipPermissionCheck = ['find', 'first']; |
|
17 | + /** |
|
18 | + * List of all route actions that the base api controller |
|
19 | + * will skip permissions check for them. |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected $skipPermissionCheck = ['find', 'first']; |
|
23 | 23 | } |
@@ -11,60 +11,60 @@ |
||
11 | 11 | */ |
12 | 12 | protected function getModel() |
13 | 13 | { |
14 | - $apiVersion = \Request::header('api-version') ?: 1; |
|
14 | + $apiVersion = \Request::header('api-version') ?: 1; |
|
15 | 15 | return 'App\Modules\Reporting\Report'; |
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
19 | - * Render the given report db view. |
|
20 | - * |
|
21 | - * @param integer $id |
|
22 | - * @param array $relations |
|
23 | - * @param array $columns |
|
24 | - * @return object |
|
25 | - */ |
|
26 | - public function find($id, $relations = [], $columns = array('*')) |
|
27 | - { |
|
19 | + * Render the given report db view. |
|
20 | + * |
|
21 | + * @param integer $id |
|
22 | + * @param array $relations |
|
23 | + * @param array $columns |
|
24 | + * @return object |
|
25 | + */ |
|
26 | + public function find($id, $relations = [], $columns = array('*')) |
|
27 | + { |
|
28 | 28 | $report = call_user_func_array("{$this->getModel()}::with", array($relations))->find($id, $columns); |
29 | 29 | |
30 | - if ( ! \Core::users()->can($report->view_name, 'reports')) |
|
31 | - { |
|
32 | - $error = $this->errorHandler->noPermissions(); |
|
33 | - abort($error['status'], $error['message']); |
|
34 | - } |
|
30 | + if ( ! \Core::users()->can($report->view_name, 'reports')) |
|
31 | + { |
|
32 | + $error = $this->errorHandler->noPermissions(); |
|
33 | + abort($error['status'], $error['message']); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | if ( ! $report) |
37 | 37 | { |
38 | 38 | $error = $this->errorHandler->notFound('report'); |
39 | 39 | abort($error['status'], $error['message']); |
40 | 40 | } |
41 | - return \DB::table($report->view_name)->get(); |
|
42 | - } |
|
41 | + return \DB::table($report->view_name)->get(); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Render the given report db view based on the given |
|
46 | - * condition. |
|
47 | - * |
|
48 | - * @param array $conditions array of conditions |
|
49 | - * @param array $relations |
|
50 | - * @param array $colunmns |
|
51 | - * @return object |
|
52 | - */ |
|
53 | - public function first($conditions, $relations = [], $columns = array('*')) |
|
54 | - { |
|
44 | + /** |
|
45 | + * Render the given report db view based on the given |
|
46 | + * condition. |
|
47 | + * |
|
48 | + * @param array $conditions array of conditions |
|
49 | + * @param array $relations |
|
50 | + * @param array $colunmns |
|
51 | + * @return object |
|
52 | + */ |
|
53 | + public function first($conditions, $relations = [], $columns = array('*')) |
|
54 | + { |
|
55 | 55 | $conditions = $this->constructConditions($conditions); |
56 | 56 | $report = call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->first($columns); |
57 | 57 | |
58 | - if ( ! \Core::users()->can($report->view_name, 'reports')) |
|
59 | - { |
|
60 | - $error = $this->errorHandler->noPermissions(); |
|
61 | - abort($error['status'], $error['message']); |
|
62 | - } |
|
58 | + if ( ! \Core::users()->can($report->view_name, 'reports')) |
|
59 | + { |
|
60 | + $error = $this->errorHandler->noPermissions(); |
|
61 | + abort($error['status'], $error['message']); |
|
62 | + } |
|
63 | 63 | if ( ! $report) |
64 | 64 | { |
65 | 65 | $error = $this->errorHandler->notFound('report'); |
66 | 66 | abort($error['status'], $error['message']); |
67 | 67 | } |
68 | - return \DB::table($report->view_name)->get(); |
|
69 | - } |
|
68 | + return \DB::table($report->view_name)->get(); |
|
69 | + } |
|
70 | 70 | } |