Completed
Push — master ( 6c0ec9...eb7f3e )
by Sherif
04:21
created
src/Modules/V1/Notifications/Http/Controllers/NotificationsController.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -8,30 +8,30 @@
 block discarded – undo
8 8
 class NotificationsController 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            = 'notifications';
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            = 'notifications';
16 16
 
17
-    /**
18
-     * Set the notification notified to true.
19
-     * 
20
-     * @param  integer  $id Id of the notification.
21
-     * @return \Illuminate\Http\Response
22
-     */
23
-    public function notified($id)
24
-    {
25
-        return \Response::json(\Core::notifications()->notified($id), 200);
26
-    }
17
+	/**
18
+	 * Set the notification notified to true.
19
+	 * 
20
+	 * @param  integer  $id Id of the notification.
21
+	 * @return \Illuminate\Http\Response
22
+	 */
23
+	public function notified($id)
24
+	{
25
+		return \Response::json(\Core::notifications()->notified($id), 200);
26
+	}
27 27
 
28
-    /**
29
-     * Set the notification notified to all.
30
-     * 
31
-     * @return \Illuminate\Http\Response
32
-     */
33
-    public function notifyall()
34
-    {
35
-        return \Response::json(\Core::notifications()->notifyAll(), 200);
36
-    }
28
+	/**
29
+	 * Set the notification notified to all.
30
+	 * 
31
+	 * @return \Illuminate\Http\Response
32
+	 */
33
+	public function notifyall()
34
+	{
35
+		return \Response::json(\Core::notifications()->notifyAll(), 200);
36
+	}
37 37
 }
Please login to merge, or discard this patch.
src/Modules/V1/Reporting/Http/Controllers/ReportsController.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -7,33 +7,33 @@
 block discarded – undo
7 7
 
8 8
 class ReportsController extends BaseApiController
9 9
 {
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';
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';
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 = ['getReport'];
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 = ['getReport'];
23 23
 
24
-    /**
25
-     * Render the given report name with the given conditions.
26
-     *
27
-     * @param  \Illuminate\Http\Request  $request
28
-     * @param  string  $reportName Name of the requested report
29
-     * @param  integer $perPage    Number of rows per page default all data.
30
-     * @return \Illuminate\Http\Response
31
-     */
32
-    public function getReport(Request $request, $reportName, $perPage = 0) 
33
-    {
34
-        if ($this->model) 
35
-        {
36
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->getReport($reportName, $request->all(), $perPage), 200);
37
-        }
38
-    }
24
+	/**
25
+	 * Render the given report name with the given conditions.
26
+	 *
27
+	 * @param  \Illuminate\Http\Request  $request
28
+	 * @param  string  $reportName Name of the requested report
29
+	 * @param  integer $perPage    Number of rows per page default all data.
30
+	 * @return \Illuminate\Http\Response
31
+	 */
32
+	public function getReport(Request $request, $reportName, $perPage = 0) 
33
+	{
34
+		if ($this->model) 
35
+		{
36
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->getReport($reportName, $request->all(), $perPage), 200);
37
+		}
38
+	}
39 39
 }
Please login to merge, or discard this patch.
src/Modules/V1/Core/Http/Controllers/BaseApiController.php 1 patch
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -6,297 +6,297 @@
 block discarded – undo
6 6
 
7 7
 class BaseApiController extends Controller
8 8
 {
9
-    /**
10
-     * The model implementation.
11
-     * 
12
-     * @var string
13
-     */
14
-    protected $model;
9
+	/**
10
+	 * The model implementation.
11
+	 * 
12
+	 * @var string
13
+	 */
14
+	protected $model;
15 15
 
16
-    /**
17
-     * The config implementation.
18
-     * 
19
-     * @var array
20
-     */
21
-    protected $config;
16
+	/**
17
+	 * The config implementation.
18
+	 * 
19
+	 * @var array
20
+	 */
21
+	protected $config;
22 22
 
23
-    /**
24
-     * The relations implementation.
25
-     * 
26
-     * @var array
27
-     */
28
-    protected $relations;
23
+	/**
24
+	 * The relations implementation.
25
+	 * 
26
+	 * @var array
27
+	 */
28
+	protected $relations;
29 29
 
30
-    public function __construct()
31
-    {        
32
-        $this->config              = \CoreConfig::getConfig();
33
-        $this->model               = property_exists($this, 'model') ? $this->model : false;
34
-        $this->validationRules     = property_exists($this, 'validationRules') ? $this->validationRules : false;
35
-        $this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : [];
36
-        $this->skipLoginCheck      = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : [];
37
-        $route                     = explode('@',\Route::currentRouteAction())[1];
30
+	public function __construct()
31
+	{        
32
+		$this->config              = \CoreConfig::getConfig();
33
+		$this->model               = property_exists($this, 'model') ? $this->model : false;
34
+		$this->validationRules     = property_exists($this, 'validationRules') ? $this->validationRules : false;
35
+		$this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : [];
36
+		$this->skipLoginCheck      = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : [];
37
+		$route                     = explode('@',\Route::currentRouteAction())[1];
38 38
 
39
-        $this->checkPermission($route);
40
-        $this->setRelations($route);
41
-        $this->setSessions();
42
-    }
39
+		$this->checkPermission($route);
40
+		$this->setRelations($route);
41
+		$this->setSessions();
42
+	}
43 43
 
44
-    /**
45
-     * Fetch all records with relations from storage.
46
-     * 
47
-     * @param  string  $sortBy The name of the column to sort by.
48
-     * @param  boolean $desc   Sort ascending or descinding (1: desc, 0: asc).
49
-     * @return \Illuminate\Http\Response
50
-     */
51
-    public function index($sortBy = 'created_at', $desc = 1) 
52
-    {
53
-        if ($this->model)
54
-        {
55
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->all($this->relations, $sortBy, $desc), 200);
56
-        }
57
-    }
44
+	/**
45
+	 * Fetch all records with relations from storage.
46
+	 * 
47
+	 * @param  string  $sortBy The name of the column to sort by.
48
+	 * @param  boolean $desc   Sort ascending or descinding (1: desc, 0: asc).
49
+	 * @return \Illuminate\Http\Response
50
+	 */
51
+	public function index($sortBy = 'created_at', $desc = 1) 
52
+	{
53
+		if ($this->model)
54
+		{
55
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->all($this->relations, $sortBy, $desc), 200);
56
+		}
57
+	}
58 58
 
59
-    /**
60
-     * Fetch the single object with relations from storage.
61
-     * 
62
-     * @param  integer $id Id of the requested model.
63
-     * @return \Illuminate\Http\Response
64
-     */
65
-    public function find($id) 
66
-    {
67
-        if ($this->model) 
68
-        {
69
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->find($id, $this->relations), 200);
70
-        }
71
-    }
59
+	/**
60
+	 * Fetch the single object with relations from storage.
61
+	 * 
62
+	 * @param  integer $id Id of the requested model.
63
+	 * @return \Illuminate\Http\Response
64
+	 */
65
+	public function find($id) 
66
+	{
67
+		if ($this->model) 
68
+		{
69
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->find($id, $this->relations), 200);
70
+		}
71
+	}
72 72
 
73
-    /**
74
-     * Paginate all records with relations from storage
75
-     * that matche the given query.
76
-     * 
77
-     * @param  string  $query   The search text.
78
-     * @param  integer $perPage Number of rows per page default 15.
79
-     * @param  string  $sortBy  The name of the column to sort by.
80
-     * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
81
-     * @return \Illuminate\Http\Response
82
-     */
83
-    public function search($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) 
84
-    {
85
-        if ($this->model) 
86
-        {
87
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->search($query, $perPage, $this->relations, $sortBy, $desc), 200);
88
-        }
89
-    }
73
+	/**
74
+	 * Paginate all records with relations from storage
75
+	 * that matche the given query.
76
+	 * 
77
+	 * @param  string  $query   The search text.
78
+	 * @param  integer $perPage Number of rows per page default 15.
79
+	 * @param  string  $sortBy  The name of the column to sort by.
80
+	 * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
81
+	 * @return \Illuminate\Http\Response
82
+	 */
83
+	public function search($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) 
84
+	{
85
+		if ($this->model) 
86
+		{
87
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->search($query, $perPage, $this->relations, $sortBy, $desc), 200);
88
+		}
89
+	}
90 90
 
91
-    /**
92
-     * Fetch records from the storage based on the given
93
-     * condition.
94
-     * 
95
-     * @param  \Illuminate\Http\Request  $request
96
-     * @param  string  $sortBy The name of the column to sort by.
97
-     * @param  boolean $desc   Sort ascending or descinding (1: desc, 0: asc).
98
-     * @return \Illuminate\Http\Response
99
-     */
100
-    public function findby(Request $request, $sortBy = 'created_at', $desc = 1) 
101
-    {
102
-        if ($this->model) 
103
-        {
104
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->findBy($request->all(), $this->relations, $sortBy, $desc), 200);
105
-        }
106
-    }
91
+	/**
92
+	 * Fetch records from the storage based on the given
93
+	 * condition.
94
+	 * 
95
+	 * @param  \Illuminate\Http\Request  $request
96
+	 * @param  string  $sortBy The name of the column to sort by.
97
+	 * @param  boolean $desc   Sort ascending or descinding (1: desc, 0: asc).
98
+	 * @return \Illuminate\Http\Response
99
+	 */
100
+	public function findby(Request $request, $sortBy = 'created_at', $desc = 1) 
101
+	{
102
+		if ($this->model) 
103
+		{
104
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->findBy($request->all(), $this->relations, $sortBy, $desc), 200);
105
+		}
106
+	}
107 107
 
108
-    /**
109
-     * Fetch the first record from the storage based on the given
110
-     * condition.
111
-     * 
112
-     * @param  \Illuminate\Http\Request  $request
113
-     * @return \Illuminate\Http\Response
114
-     */
115
-    public function first(Request $request) 
116
-    {
117
-        if ($this->model) 
118
-        {
119
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->first($request->all(), $this->relations), 200);
120
-        }
121
-    }
108
+	/**
109
+	 * Fetch the first record from the storage based on the given
110
+	 * condition.
111
+	 * 
112
+	 * @param  \Illuminate\Http\Request  $request
113
+	 * @return \Illuminate\Http\Response
114
+	 */
115
+	public function first(Request $request) 
116
+	{
117
+		if ($this->model) 
118
+		{
119
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->first($request->all(), $this->relations), 200);
120
+		}
121
+	}
122 122
 
123
-    /**
124
-     * Paginate all records with relations from storage.
125
-     * 
126
-     * @param  integer $perPage Number of rows per page default 15.
127
-     * @param  string  $sortBy  The name of the column to sort by.
128
-     * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
129
-     * @return \Illuminate\Http\Response
130
-     */
131
-    public function paginate($perPage = 15, $sortBy = 'created_at', $desc = 1) 
132
-    {
133
-        if ($this->model) 
134
-        {
135
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->paginate($perPage, $this->relations, $sortBy, $desc), 200);
136
-        }
137
-    }
123
+	/**
124
+	 * Paginate all records with relations from storage.
125
+	 * 
126
+	 * @param  integer $perPage Number of rows per page default 15.
127
+	 * @param  string  $sortBy  The name of the column to sort by.
128
+	 * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
129
+	 * @return \Illuminate\Http\Response
130
+	 */
131
+	public function paginate($perPage = 15, $sortBy = 'created_at', $desc = 1) 
132
+	{
133
+		if ($this->model) 
134
+		{
135
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->paginate($perPage, $this->relations, $sortBy, $desc), 200);
136
+		}
137
+	}
138 138
 
139
-    /**
140
-     * Fetch all records with relations based on
141
-     * the given condition from storage in pages.
142
-     * 
143
-     * @param  \Illuminate\Http\Request  $request
144
-     * @param  integer $perPage Number of rows per page default 15.
145
-     * @param  string  $sortBy  The name of the column to sort by.
146
-     * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
147
-     * @return \Illuminate\Http\Response
148
-     */
149
-    public function paginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
150
-    {
151
-        if ($this->model) 
152
-        {
153
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->paginateBy($request->all(), $perPage, $this->relations, $sortBy, $desc), 200);
154
-        }
155
-    }
139
+	/**
140
+	 * Fetch all records with relations based on
141
+	 * the given condition from storage in pages.
142
+	 * 
143
+	 * @param  \Illuminate\Http\Request  $request
144
+	 * @param  integer $perPage Number of rows per page default 15.
145
+	 * @param  string  $sortBy  The name of the column to sort by.
146
+	 * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
147
+	 * @return \Illuminate\Http\Response
148
+	 */
149
+	public function paginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
150
+	{
151
+		if ($this->model) 
152
+		{
153
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->paginateBy($request->all(), $perPage, $this->relations, $sortBy, $desc), 200);
154
+		}
155
+	}
156 156
 
157
-    /**
158
-     * Save the given model to storage.
159
-     * 
160
-     * @param  \Illuminate\Http\Request  $request
161
-     * @return \Illuminate\Http\Response
162
-     */
163
-    public function save(Request $request) 
164
-    {
165
-        foreach ($this->validationRules as &$rule) 
166
-        {
167
-            if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) 
168
-            {
169
-                $rule .= ',deleted_at,NULL';
170
-            }
157
+	/**
158
+	 * Save the given model to storage.
159
+	 * 
160
+	 * @param  \Illuminate\Http\Request  $request
161
+	 * @return \Illuminate\Http\Response
162
+	 */
163
+	public function save(Request $request) 
164
+	{
165
+		foreach ($this->validationRules as &$rule) 
166
+		{
167
+			if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) 
168
+			{
169
+				$rule .= ',deleted_at,NULL';
170
+			}
171 171
 
172
-            if ($request->has('id')) 
173
-            {
174
-                $rule = str_replace('{id}', $request->get('id'), $rule);
175
-            }
176
-            else
177
-            {
178
-                $rule = str_replace(',{id}', '', $rule);
179
-            }
180
-        }
172
+			if ($request->has('id')) 
173
+			{
174
+				$rule = str_replace('{id}', $request->get('id'), $rule);
175
+			}
176
+			else
177
+			{
178
+				$rule = str_replace(',{id}', '', $rule);
179
+			}
180
+		}
181 181
         
182
-        $this->validate($request, $this->validationRules);
182
+		$this->validate($request, $this->validationRules);
183 183
 
184
-        if ($this->model) 
185
-        {
186
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->save($request->all()), 200);
187
-        }
188
-    }
184
+		if ($this->model) 
185
+		{
186
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->save($request->all()), 200);
187
+		}
188
+	}
189 189
 
190
-    /**
191
-     * Delete by the given id from storage.
192
-     * 
193
-     * @param  integer $id Id of the deleted model.
194
-     * @return \Illuminate\Http\Response
195
-     */
196
-    public function delete($id) 
197
-    {
198
-        if ($this->model) 
199
-        {
200
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->delete($id), 200);
201
-        }
202
-    }
190
+	/**
191
+	 * Delete by the given id from storage.
192
+	 * 
193
+	 * @param  integer $id Id of the deleted model.
194
+	 * @return \Illuminate\Http\Response
195
+	 */
196
+	public function delete($id) 
197
+	{
198
+		if ($this->model) 
199
+		{
200
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->delete($id), 200);
201
+		}
202
+	}
203 203
 
204
-    /**
205
-     * Return the deleted models in pages based on the given conditions.
206
-     *
207
-     * @param  \Illuminate\Http\Request  $request
208
-     * @param  integer $perPage Number of rows per page default 15.
209
-     * @param  string  $sortBy  The name of the column to sort by.
210
-     * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
211
-     * @return \Illuminate\Http\Response
212
-     */
213
-    public function deleted(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
214
-    {
215
-        return \Response::json(call_user_func_array("\Core::{$this->model}", [])->deleted($request->all(), $perPage, $sortBy, $desc), 200);
216
-    }
204
+	/**
205
+	 * Return the deleted models in pages based on the given conditions.
206
+	 *
207
+	 * @param  \Illuminate\Http\Request  $request
208
+	 * @param  integer $perPage Number of rows per page default 15.
209
+	 * @param  string  $sortBy  The name of the column to sort by.
210
+	 * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
211
+	 * @return \Illuminate\Http\Response
212
+	 */
213
+	public function deleted(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
214
+	{
215
+		return \Response::json(call_user_func_array("\Core::{$this->model}", [])->deleted($request->all(), $perPage, $sortBy, $desc), 200);
216
+	}
217 217
 
218
-    /**
219
-     * Restore the deleted model.
220
-     * 
221
-     * @param  integer $id Id of the restored model.
222
-     * @return \Illuminate\Http\Response
223
-     */
224
-    public function restore($id) 
225
-    {
226
-        if ($this->model) 
227
-        {
228
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->restore($id), 200);
229
-        }
230
-    }
218
+	/**
219
+	 * Restore the deleted model.
220
+	 * 
221
+	 * @param  integer $id Id of the restored model.
222
+	 * @return \Illuminate\Http\Response
223
+	 */
224
+	public function restore($id) 
225
+	{
226
+		if ($this->model) 
227
+		{
228
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->restore($id), 200);
229
+		}
230
+	}
231 231
 
232
-    /**
233
-     * Check if the logged in user can do the given permission.
234
-     * 
235
-     * @param  string $permission
236
-     * @return void
237
-     */
238
-    private function checkPermission($permission)
239
-    {
240
-        $permission = $permission !== 'index' ? $permission : 'list';
241
-        if ( ! in_array($permission, $this->skipLoginCheck)) 
242
-        {
243
-            $user = \Core::users()->find(\JWTAuth::parseToken()->authenticate()->id);
244
-            if ($user->blocked)
245
-            {
246
-                \ErrorHandler::userIsBlocked();
247
-            }
232
+	/**
233
+	 * Check if the logged in user can do the given permission.
234
+	 * 
235
+	 * @param  string $permission
236
+	 * @return void
237
+	 */
238
+	private function checkPermission($permission)
239
+	{
240
+		$permission = $permission !== 'index' ? $permission : 'list';
241
+		if ( ! in_array($permission, $this->skipLoginCheck)) 
242
+		{
243
+			$user = \Core::users()->find(\JWTAuth::parseToken()->authenticate()->id);
244
+			if ($user->blocked)
245
+			{
246
+				\ErrorHandler::userIsBlocked();
247
+			}
248 248
             
249
-            if ( ! in_array($permission, $this->skipPermissionCheck) && ! \Core::users()->can($permission, $this->model))
250
-            {
251
-                \ErrorHandler::noPermissions();
252
-            }
253
-        }
254
-    }
249
+			if ( ! in_array($permission, $this->skipPermissionCheck) && ! \Core::users()->can($permission, $this->model))
250
+			{
251
+				\ErrorHandler::noPermissions();
252
+			}
253
+		}
254
+	}
255 255
 
256
-    /**
257
-     * Set sessions based on the given headers in the request.
258
-     * 
259
-     * @return void
260
-     */
261
-    private function setSessions()
262
-    {
263
-        \Session::put('timeZoneDiff', \Request::header('time-zone-diff') ?: 0);
256
+	/**
257
+	 * Set sessions based on the given headers in the request.
258
+	 * 
259
+	 * @return void
260
+	 */
261
+	private function setSessions()
262
+	{
263
+		\Session::put('timeZoneDiff', \Request::header('time-zone-diff') ?: 0);
264 264
 
265
-        $locale = \Request::header('locale');
266
-        switch ($locale) 
267
-        {
268
-            case 'en':
269
-            \App::setLocale('en');
270
-            \Session::put('locale', 'en');
271
-            break;
265
+		$locale = \Request::header('locale');
266
+		switch ($locale) 
267
+		{
268
+			case 'en':
269
+			\App::setLocale('en');
270
+			\Session::put('locale', 'en');
271
+			break;
272 272
 
273
-            case 'ar':
274
-            \App::setLocale('ar');
275
-            \Session::put('locale', 'ar');
276
-            break;
273
+			case 'ar':
274
+			\App::setLocale('ar');
275
+			\Session::put('locale', 'ar');
276
+			break;
277 277
 
278
-            case 'all':
279
-            \App::setLocale('en');
280
-            \Session::put('locale', 'all');
281
-            break;
278
+			case 'all':
279
+			\App::setLocale('en');
280
+			\Session::put('locale', 'all');
281
+			break;
282 282
 
283
-            default:
284
-            \App::setLocale('en');
285
-            \Session::put('locale', 'en');
286
-            break;
287
-        }
288
-    }
283
+			default:
284
+			\App::setLocale('en');
285
+			\Session::put('locale', 'en');
286
+			break;
287
+		}
288
+	}
289 289
 
290
-    /**
291
-     * Set relation based on the called api.
292
-     * 
293
-     * @param  string $route
294
-     * @return void
295
-     */
296
-    private function setRelations($route)
297
-    {
298
-        $route           = $route !== 'index' ? $route : 'list';
299
-        $relations       = array_key_exists($this->model, $this->config['relations']) ? $this->config['relations'][$this->model] : false;
300
-        $this->relations = $relations && $relations[$route] ? $relations[$route] : [];
301
-    }
290
+	/**
291
+	 * Set relation based on the called api.
292
+	 * 
293
+	 * @param  string $route
294
+	 * @return void
295
+	 */
296
+	private function setRelations($route)
297
+	{
298
+		$route           = $route !== 'index' ? $route : 'list';
299
+		$relations       = array_key_exists($this->model, $this->config['relations']) ? $this->config['relations'][$this->model] : false;
300
+		$this->relations = $relations && $relations[$route] ? $relations[$route] : [];
301
+	}
302 302
 }
Please login to merge, or discard this patch.
src/Modules/V1/Core/Utl/ErrorHandler.php 1 patch
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -2,105 +2,105 @@
 block discarded – undo
2 2
 
3 3
 class ErrorHandler
4 4
 {
5
-    public function unAuthorized()
6
-    {
7
-        $error = ['status' => 401, 'message' => trans('errors.unAuthorized')];
8
-        abort($error['status'], $error['message']);
9
-    }
10
-
11
-    public function tokenExpired()
12
-    {
13
-        $error = ['status' => 403, 'message' => trans('errors.tokenExpired')];
14
-        abort($error['status'], $error['message']);
15
-    }
16
-
17
-     public function noPermissions()
18
-    {
19
-        $error = ['status' => 403, 'message' => trans('errors.noPermissions')];
20
-        abort($error['status'], $error['message']);
21
-    }
22
-
23
-    public function loginFailed()
24
-    {
25
-        $error = ['status' => 400, 'message' => trans('errors.loginFailed')];
26
-        abort($error['status'], $error['message']);
27
-    }
28
-
29
-    public function noSocialEmail()
30
-    {
31
-        $error = ['status' => 400, 'message' => trans('errors.noSocialEmail')];
32
-        abort($error['status'], $error['message']);
33
-    }
34
-
35
-    public function userAlreadyRegistered()
36
-    {
37
-        $error = ['status' => 400, 'message' => trans('errors.userAlreadyRegistered')];
38
-        abort($error['status'], $error['message']);
39
-    }
40
-
41
-    public function connectionError()
42
-    {
43
-        $error = ['status' => 400, 'message' => trans('errors.connectionError')];
44
-        abort($error['status'], $error['message']);
45
-    }
46
-
47
-    public function redisNotRunning()
48
-    {
49
-        $error = ['status' => 400, 'message' => trans('errors.redisNotRunning')];
50
-        abort($error['status'], $error['message']);
51
-    }
52
-
53
-    public function dbQueryError()
54
-    {
55
-        $error = ['status' => 400, 'message' => trans('errors.dbQueryError')];
56
-        abort($error['status'], $error['message']);
57
-    }
58
-
59
-    public function cannotCreateSetting()
60
-    {
61
-        $error = ['status' => 400, 'message' => trans('errors.cannotCreateSetting')];
62
-        abort($error['status'], $error['message']);
63
-    }
64
-
65
-    public function cannotUpdateSettingKey()
66
-    {
67
-        $error = ['status' => 400, 'message' => trans('errors.cannotUpdateSettingKey')];
68
-        abort($error['status'], $error['message']);
69
-    }
70
-
71
-    public function userIsBlocked()
72
-    {
73
-        $error = ['status' => 403, 'message' => trans('errors.userIsBlocked')];
74
-        abort($error['status'], $error['message']);
75
-    }
76
-
77
-    public function invalidResetToken()
78
-    {
79
-        $error = ['status' => 400, 'message' => trans('errors.invalidResetToken')];
80
-        abort($error['status'], $error['message']);
81
-    }
82
-
83
-    public function invalidResetPassword()
84
-    {
85
-        $error = ['status' => 400, 'message' => trans('errors.invalidResetPassword')];
86
-        abort($error['status'], $error['message']);
87
-    }
88
-
89
-    public function invalidOldPassword()
90
-    {
91
-        $error = ['status' => 400, 'message' => trans('errors.invalidOldPassword')];
92
-        abort($error['status'], $error['message']);
93
-    }
94
-
95
-    public function notFound($text)
96
-    {
97
-        $error = ['status' => 404, 'message' => trans('errors.notFound', ['replace' => $text])];
98
-        abort($error['status'], $error['message']);
99
-    }
100
-
101
-    public function generalError()
102
-    {
103
-        $error = ['status' => 400, 'message' => trans('errors.generalError')];
104
-        abort($error['status'], $error['message']);
105
-    }
5
+	public function unAuthorized()
6
+	{
7
+		$error = ['status' => 401, 'message' => trans('errors.unAuthorized')];
8
+		abort($error['status'], $error['message']);
9
+	}
10
+
11
+	public function tokenExpired()
12
+	{
13
+		$error = ['status' => 403, 'message' => trans('errors.tokenExpired')];
14
+		abort($error['status'], $error['message']);
15
+	}
16
+
17
+	 public function noPermissions()
18
+	{
19
+		$error = ['status' => 403, 'message' => trans('errors.noPermissions')];
20
+		abort($error['status'], $error['message']);
21
+	}
22
+
23
+	public function loginFailed()
24
+	{
25
+		$error = ['status' => 400, 'message' => trans('errors.loginFailed')];
26
+		abort($error['status'], $error['message']);
27
+	}
28
+
29
+	public function noSocialEmail()
30
+	{
31
+		$error = ['status' => 400, 'message' => trans('errors.noSocialEmail')];
32
+		abort($error['status'], $error['message']);
33
+	}
34
+
35
+	public function userAlreadyRegistered()
36
+	{
37
+		$error = ['status' => 400, 'message' => trans('errors.userAlreadyRegistered')];
38
+		abort($error['status'], $error['message']);
39
+	}
40
+
41
+	public function connectionError()
42
+	{
43
+		$error = ['status' => 400, 'message' => trans('errors.connectionError')];
44
+		abort($error['status'], $error['message']);
45
+	}
46
+
47
+	public function redisNotRunning()
48
+	{
49
+		$error = ['status' => 400, 'message' => trans('errors.redisNotRunning')];
50
+		abort($error['status'], $error['message']);
51
+	}
52
+
53
+	public function dbQueryError()
54
+	{
55
+		$error = ['status' => 400, 'message' => trans('errors.dbQueryError')];
56
+		abort($error['status'], $error['message']);
57
+	}
58
+
59
+	public function cannotCreateSetting()
60
+	{
61
+		$error = ['status' => 400, 'message' => trans('errors.cannotCreateSetting')];
62
+		abort($error['status'], $error['message']);
63
+	}
64
+
65
+	public function cannotUpdateSettingKey()
66
+	{
67
+		$error = ['status' => 400, 'message' => trans('errors.cannotUpdateSettingKey')];
68
+		abort($error['status'], $error['message']);
69
+	}
70
+
71
+	public function userIsBlocked()
72
+	{
73
+		$error = ['status' => 403, 'message' => trans('errors.userIsBlocked')];
74
+		abort($error['status'], $error['message']);
75
+	}
76
+
77
+	public function invalidResetToken()
78
+	{
79
+		$error = ['status' => 400, 'message' => trans('errors.invalidResetToken')];
80
+		abort($error['status'], $error['message']);
81
+	}
82
+
83
+	public function invalidResetPassword()
84
+	{
85
+		$error = ['status' => 400, 'message' => trans('errors.invalidResetPassword')];
86
+		abort($error['status'], $error['message']);
87
+	}
88
+
89
+	public function invalidOldPassword()
90
+	{
91
+		$error = ['status' => 400, 'message' => trans('errors.invalidOldPassword')];
92
+		abort($error['status'], $error['message']);
93
+	}
94
+
95
+	public function notFound($text)
96
+	{
97
+		$error = ['status' => 404, 'message' => trans('errors.notFound', ['replace' => $text])];
98
+		abort($error['status'], $error['message']);
99
+	}
100
+
101
+	public function generalError()
102
+	{
103
+		$error = ['status' => 400, 'message' => trans('errors.generalError')];
104
+		abort($error['status'], $error['message']);
105
+	}
106 106
 }
107 107
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/V1/Core/Decorators/CachingDecorator.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -2,96 +2,96 @@
 block discarded – undo
2 2
 
3 3
 class CachingDecorator
4 4
 {
5
-    /**
6
-     * The repo implementation.
7
-     * 
8
-     * @var string
9
-     */
10
-    public $repo;
5
+	/**
6
+	 * The repo implementation.
7
+	 * 
8
+	 * @var string
9
+	 */
10
+	public $repo;
11 11
 
12
-    /**
13
-     * The cache implementation.
14
-     * 
15
-     * @var object
16
-     */
17
-    protected $cache;
12
+	/**
13
+	 * The cache implementation.
14
+	 * 
15
+	 * @var object
16
+	 */
17
+	protected $cache;
18 18
 
19
-    /**
20
-     * The model implementation.
21
-     * 
22
-     * @var string
23
-     */
24
-    public $model;
19
+	/**
20
+	 * The model implementation.
21
+	 * 
22
+	 * @var string
23
+	 */
24
+	public $model;
25 25
 
26
-    /**
27
-     * The cacheConfig implementation.
28
-     * 
29
-     * @var array
30
-     */
31
-    public $cacheConfig;
26
+	/**
27
+	 * The cacheConfig implementation.
28
+	 * 
29
+	 * @var array
30
+	 */
31
+	public $cacheConfig;
32 32
     
33
-    /**
34
-     * Create new CachingDecorator instance.
35
-     */
36
-    public function __construct($repo, $cache)
37
-    {   
38
-        $this->repo  = $repo;
39
-        $this->cache = $cache;
40
-        $this->model = get_class($this->repo->model);
41
-    }
33
+	/**
34
+	 * Create new CachingDecorator instance.
35
+	 */
36
+	public function __construct($repo, $cache)
37
+	{   
38
+		$this->repo  = $repo;
39
+		$this->cache = $cache;
40
+		$this->model = get_class($this->repo->model);
41
+	}
42 42
 
43
-    /**
44
-     * Handle the cache mechanism for the called method
45
-     * based the configurations.
46
-     * 
47
-     * @param  string $name the called method name
48
-     * @param  array  $arguments the method arguments
49
-     * @return object
50
-     */
51
-    public function __call($name, $arguments)
52
-    {
53
-        $this->setCacheConfig($name);
43
+	/**
44
+	 * Handle the cache mechanism for the called method
45
+	 * based the configurations.
46
+	 * 
47
+	 * @param  string $name the called method name
48
+	 * @param  array  $arguments the method arguments
49
+	 * @return object
50
+	 */
51
+	public function __call($name, $arguments)
52
+	{
53
+		$this->setCacheConfig($name);
54 54
 
55
-        if ($this->cacheConfig && $this->cacheConfig == 'cache') 
56
-        {
57
-            $page     = \Request::get('page') ?? '1';
58
-            $cacheKey = $name . $page . serialize($arguments);
59
-            return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($arguments, $name) {
60
-                return call_user_func_array([$this->repo, $name], $arguments);
61
-            });
62
-        }
63
-        else if ($this->cacheConfig)
64
-        {
65
-            $this->cache->tags($this->cacheConfig)->flush();
66
-            return call_user_func_array([$this->repo, $name], $arguments);
67
-        }
55
+		if ($this->cacheConfig && $this->cacheConfig == 'cache') 
56
+		{
57
+			$page     = \Request::get('page') ?? '1';
58
+			$cacheKey = $name . $page . serialize($arguments);
59
+			return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($arguments, $name) {
60
+				return call_user_func_array([$this->repo, $name], $arguments);
61
+			});
62
+		}
63
+		else if ($this->cacheConfig)
64
+		{
65
+			$this->cache->tags($this->cacheConfig)->flush();
66
+			return call_user_func_array([$this->repo, $name], $arguments);
67
+		}
68 68
 
69
-        return call_user_func_array([$this->repo, $name], $arguments);
70
-    }
69
+		return call_user_func_array([$this->repo, $name], $arguments);
70
+	}
71 71
 
72
-    /**
73
-     * Set cache config based on the called method.
74
-     * 
75
-     * @param  string $name
76
-     * @return void
77
-     */
78
-    private function setCacheConfig($name)
79
-    {
80
-        $strArr            = explode('\\', get_class($this->repo));
81
-        $repoName          = end($strArr);
82
-        $configKey         = str_plural(strtolower(substr($repoName, 0, strpos($repoName, 'Repository'))));
72
+	/**
73
+	 * Set cache config based on the called method.
74
+	 * 
75
+	 * @param  string $name
76
+	 * @return void
77
+	 */
78
+	private function setCacheConfig($name)
79
+	{
80
+		$strArr            = explode('\\', get_class($this->repo));
81
+		$repoName          = end($strArr);
82
+		$configKey         = str_plural(strtolower(substr($repoName, 0, strpos($repoName, 'Repository'))));
83 83
         
84
-        $config            = \CoreConfig::getConfig();
85
-        $cacheConfig       = array_key_exists($configKey, $config['cacheConfig']) ? $config['cacheConfig'][$configKey] : false;
86
-        $this->cacheConfig = false;
84
+		$config            = \CoreConfig::getConfig();
85
+		$cacheConfig       = array_key_exists($configKey, $config['cacheConfig']) ? $config['cacheConfig'][$configKey] : false;
86
+		$this->cacheConfig = false;
87 87
 
88
-        if (in_array($name, $cacheConfig['cache']))
89
-        {
90
-            $this->cacheConfig = 'cache';
91
-        }
92
-        else if (in_array($name, $cacheConfig['clear']))
93
-        {
94
-            $this->cacheConfig = $cacheConfig['clear'][$name];
95
-        }
96
-    }
88
+		if (in_array($name, $cacheConfig['cache']))
89
+		{
90
+			$this->cacheConfig = 'cache';
91
+		}
92
+		else if (in_array($name, $cacheConfig['clear']))
93
+		{
94
+			$this->cacheConfig = $cacheConfig['clear'][$name];
95
+		}
96
+	}
97 97
 }
98 98
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/V1/Core/Database/Factories/SettingFactory.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $factory->define(App\Modules\V1\Core\Settings::class, function (Faker\Generator $faker) {
4
-    return [
4
+	return [
5 5
 		'id'         => $faker->randomDigitNotNull(),
6 6
 		'name'       => $faker->randomElement(['Company Name', 'Title', 'Header Image']),
7 7
 		'value'      => $faker->word(),
8 8
 		'key'        => $faker->word(),
9 9
 		'created_at' => $faker->dateTimeBetween('-1 years', 'now'),
10 10
 		'updated_at' => $faker->dateTimeBetween('-1 years', 'now')
11
-    ];
11
+	];
12 12
 });
Please login to merge, or discard this patch.
src/Modules/V1/Core/Database/Factories/LogFactory.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $factory->define(App\Modules\V1\Core\Log::class, function (Faker\Generator $faker) {
4
-    return [
4
+	return [
5 5
 		'id'         => $faker->randomDigitNotNull(),
6 6
 		'action'     => $faker->randomElement(['create', 'delete', 'update']),
7 7
 		'item_name ' => $faker->randomElement(['User', 'Settings', 'Group']),
@@ -9,5 +9,5 @@  discard block
 block discarded – undo
9 9
 		'user_id'    => $faker->randomDigitNotNull(),
10 10
 		'created_at' => $faker->dateTimeBetween('-1 years', 'now'),
11 11
 		'updated_at' => $faker->dateTimeBetween('-1 years', 'now')
12
-    ];
12
+	];
13 13
 });
14 14
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/V1/Core/Providers/ModuleServiceProvider.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -7,50 +7,50 @@
 block discarded – undo
7 7
 class ModuleServiceProvider extends ServiceProvider
8 8
 {
9 9
 	/**
10
-     * Bootstrap the module services.
11
-     *
12
-     * @return void
13
-     */
14
-    public function boot()
15
-    {
16
-        $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'core');
17
-        $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'core');
18
-
19
-        $factory = app('Illuminate\Database\Eloquent\Factory');
20
-        $factory->load(__DIR__.'/../Database/Factories');
21
-    }
22
-
23
-    /**
24
-     * Register the module services.
25
-     *
26
-     * @return void
27
-     */
28
-    public function register()
29
-    {
30
-        //Bind Core Facade to the IoC Container
31
-        \App::bind('Core', function()
32
-        {
33
-            return new \App\Modules\V1\Core\Core;
34
-        });
35
-
36
-        //Bind ErrorHandler Facade to the IoC Container
37
-        \App::bind('ErrorHandler', function()
38
-        {
39
-            return new \App\Modules\V1\Core\Utl\ErrorHandler;
40
-        });
41
-
42
-        //Bind CoreConfig Facade to the IoC Container
43
-        \App::bind('CoreConfig', function()
44
-        {
45
-            return new \App\Modules\V1\Core\Utl\CoreConfig;
46
-        });
47
-
48
-        //Bind Logging Facade to the IoC Container
49
-        \App::bind('Logging', function()
50
-        {
51
-            return new \App\Modules\V1\Core\Utl\Logging;
52
-        });
10
+	 * Bootstrap the module services.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function boot()
15
+	{
16
+		$this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'core');
17
+		$this->loadViewsFrom(__DIR__.'/../Resources/Views', 'core');
18
+
19
+		$factory = app('Illuminate\Database\Eloquent\Factory');
20
+		$factory->load(__DIR__.'/../Database/Factories');
21
+	}
22
+
23
+	/**
24
+	 * Register the module services.
25
+	 *
26
+	 * @return void
27
+	 */
28
+	public function register()
29
+	{
30
+		//Bind Core Facade to the IoC Container
31
+		\App::bind('Core', function()
32
+		{
33
+			return new \App\Modules\V1\Core\Core;
34
+		});
35
+
36
+		//Bind ErrorHandler Facade to the IoC Container
37
+		\App::bind('ErrorHandler', function()
38
+		{
39
+			return new \App\Modules\V1\Core\Utl\ErrorHandler;
40
+		});
41
+
42
+		//Bind CoreConfig Facade to the IoC Container
43
+		\App::bind('CoreConfig', function()
44
+		{
45
+			return new \App\Modules\V1\Core\Utl\CoreConfig;
46
+		});
47
+
48
+		//Bind Logging Facade to the IoC Container
49
+		\App::bind('Logging', function()
50
+		{
51
+			return new \App\Modules\V1\Core\Utl\Logging;
52
+		});
53 53
         
54
-        $this->app->register(RouteServiceProvider::class);
55
-    }
54
+		$this->app->register(RouteServiceProvider::class);
55
+	}
56 56
 }
Please login to merge, or discard this patch.
src/Modules/V1/Core/Console/Commands/GenerateDoc.php 1 patch
Indentation   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -6,261 +6,261 @@
 block discarded – undo
6 6
 
7 7
 class GenerateDoc extends Command
8 8
 {
9
-    /**
10
-     * The name and signature of the console command.
11
-     *
12
-     * @var string
13
-     */
14
-    protected $signature = 'doc:generate';
9
+	/**
10
+	 * The name and signature of the console command.
11
+	 *
12
+	 * @var string
13
+	 */
14
+	protected $signature = 'doc:generate';
15 15
 
16
-    /**
17
-     * The console command description.
18
-     *
19
-     * @var string
20
-     */
21
-    protected $description = 'Generate api documentation';
16
+	/**
17
+	 * The console command description.
18
+	 *
19
+	 * @var string
20
+	 */
21
+	protected $description = 'Generate api documentation';
22 22
 
23
-    /**
24
-     * Create a new command instance.
25
-     *
26
-     * @return void
27
-     */
28
-    public function __construct()
29
-    {
30
-        parent::__construct();
31
-    }
23
+	/**
24
+	 * Create a new command instance.
25
+	 *
26
+	 * @return void
27
+	 */
28
+	public function __construct()
29
+	{
30
+		parent::__construct();
31
+	}
32 32
 
33
-    /**
34
-     * Execute the console command.
35
-     *
36
-     * @return mixed
37
-     */
38
-    public function handle()
39
-    {
40
-        $docData           = [];
41
-        $docData['models'] = [];
42
-        $routes            = $this->getRoutes();
43
-        foreach ($routes as $route) 
44
-        {
45
-            if ($route) 
46
-            {
47
-                $actoinArray       = explode('@', $route['action']);
48
-                $controller        = $actoinArray[0];
49
-                $method            = $actoinArray[1];
50
-                $route['name']     = $method !== 'index' ? $method : 'list';
33
+	/**
34
+	 * Execute the console command.
35
+	 *
36
+	 * @return mixed
37
+	 */
38
+	public function handle()
39
+	{
40
+		$docData           = [];
41
+		$docData['models'] = [];
42
+		$routes            = $this->getRoutes();
43
+		foreach ($routes as $route) 
44
+		{
45
+			if ($route) 
46
+			{
47
+				$actoinArray       = explode('@', $route['action']);
48
+				$controller        = $actoinArray[0];
49
+				$method            = $actoinArray[1];
50
+				$route['name']     = $method !== 'index' ? $method : 'list';
51 51
                 
52
-                $reflectionClass   = new \ReflectionClass($controller);
53
-                $reflectionMethod  = $reflectionClass->getMethod($method);
54
-                $classProperties   = $reflectionClass->getDefaultProperties();
55
-                $skipLoginCheck    = array_key_exists('skipLoginCheck', $classProperties) ? $classProperties['skipLoginCheck'] : false;
56
-                $validationRules   = array_key_exists('validationRules', $classProperties) ? $classProperties['validationRules'] : false;
52
+				$reflectionClass   = new \ReflectionClass($controller);
53
+				$reflectionMethod  = $reflectionClass->getMethod($method);
54
+				$classProperties   = $reflectionClass->getDefaultProperties();
55
+				$skipLoginCheck    = array_key_exists('skipLoginCheck', $classProperties) ? $classProperties['skipLoginCheck'] : false;
56
+				$validationRules   = array_key_exists('validationRules', $classProperties) ? $classProperties['validationRules'] : false;
57 57
                 
58
-                $route['response'] = $this->getResponseObject($classProperties['model'], $route['name']);
58
+				$route['response'] = $this->getResponseObject($classProperties['model'], $route['name']);
59 59
 
60
-                $this->processDocBlock($route, $reflectionMethod);
61
-                $this->getHeaders($route, $reflectionClass, $method, $skipLoginCheck);
62
-                $this->getPostData($route, $reflectionMethod, $validationRules);
60
+				$this->processDocBlock($route, $reflectionMethod);
61
+				$this->getHeaders($route, $reflectionClass, $method, $skipLoginCheck);
62
+				$this->getPostData($route, $reflectionMethod, $validationRules);
63 63
 
64
-                preg_match('/api\/v1\/([^#]+)\//iU', $route['uri'], $module);
65
-                preg_match('/api\/v1\/' . $module[1] . '\/([^#]+)\//iU', $route['uri'], $model);
66
-                $docData['modules'][$module[1]][$model[1]][] = $route;
64
+				preg_match('/api\/v1\/([^#]+)\//iU', $route['uri'], $module);
65
+				preg_match('/api\/v1\/' . $module[1] . '\/([^#]+)\//iU', $route['uri'], $model);
66
+				$docData['modules'][$module[1]][$model[1]][] = $route;
67 67
 
68
-                $this->getModels($classProperties['model'], $docData);
69
-            }
70
-        }
68
+				$this->getModels($classProperties['model'], $docData);
69
+			}
70
+		}
71 71
         
72
-        $docData['errors'] = $this->getErrors();
73
-        \File::put(app_path('Modules/V1/Core/Resources/api.json'), json_encode($docData));
74
-    }
72
+		$docData['errors'] = $this->getErrors();
73
+		\File::put(app_path('Modules/V1/Core/Resources/api.json'), json_encode($docData));
74
+	}
75 75
 
76
-    /**
77
-     * Get list of all registered routes.
78
-     * 
79
-     * @return collection
80
-     */
81
-    protected function getRoutes()
82
-    {
83
-        return collect(\Route::getRoutes())->map(function ($route) {
84
-            if (strpos($route->uri(), 'api/v') !== false) 
85
-            {
86
-                return [
87
-                    'method' => $route->methods()[0],
88
-                    'uri'    => $route->uri(),
89
-                    'action' => $route->getActionName()
90
-                ];
91
-            }
92
-            return false;
93
-        })->all();
94
-    }
76
+	/**
77
+	 * Get list of all registered routes.
78
+	 * 
79
+	 * @return collection
80
+	 */
81
+	protected function getRoutes()
82
+	{
83
+		return collect(\Route::getRoutes())->map(function ($route) {
84
+			if (strpos($route->uri(), 'api/v') !== false) 
85
+			{
86
+				return [
87
+					'method' => $route->methods()[0],
88
+					'uri'    => $route->uri(),
89
+					'action' => $route->getActionName()
90
+				];
91
+			}
92
+			return false;
93
+		})->all();
94
+	}
95 95
 
96
-    /**
97
-     * Generate headers for the given route.
98
-     * 
99
-     * @param  array  &$route
100
-     * @param  object $reflectionClass
101
-     * @param  string $method
102
-     * @param  array  $skipLoginCheck
103
-     * @return void
104
-     */
105
-    protected function getHeaders(&$route, $reflectionClass, $method, $skipLoginCheck)
106
-    {
107
-        $route['headers'] = [
108
-        'Accept'         => 'application/json',
109
-        'Content-Type'   => 'application/json',
110
-        'locale'         => 'The language of the returned data: ar, en or all.',
111
-        'time-zone-diff' => 'Timezone difference between UTC and Local Time',
112
-        ];
96
+	/**
97
+	 * Generate headers for the given route.
98
+	 * 
99
+	 * @param  array  &$route
100
+	 * @param  object $reflectionClass
101
+	 * @param  string $method
102
+	 * @param  array  $skipLoginCheck
103
+	 * @return void
104
+	 */
105
+	protected function getHeaders(&$route, $reflectionClass, $method, $skipLoginCheck)
106
+	{
107
+		$route['headers'] = [
108
+		'Accept'         => 'application/json',
109
+		'Content-Type'   => 'application/json',
110
+		'locale'         => 'The language of the returned data: ar, en or all.',
111
+		'time-zone-diff' => 'Timezone difference between UTC and Local Time',
112
+		];
113 113
 
114 114
 
115
-        if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) 
116
-        {
117
-            $route['headers']['Authrization'] = 'bearer {token}';
118
-        }
119
-    }
115
+		if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) 
116
+		{
117
+			$route['headers']['Authrization'] = 'bearer {token}';
118
+		}
119
+	}
120 120
 
121
-    /**
122
-     * Generate description and params for the given route
123
-     * based on the docblock.
124
-     * 
125
-     * @param  array  &$route
126
-     * @param  object $reflectionMethod]
127
-     * @return void
128
-     */
129
-    protected function processDocBlock(&$route, $reflectionMethod)
130
-    {
131
-        $factory              = \phpDocumentor\Reflection\DocBlockFactory::createInstance();
132
-        $docblock             = $factory->create($reflectionMethod->getDocComment());
133
-        $route['description'] = trim(preg_replace('/\s+/', ' ', $docblock->getSummary()));
134
-        $params               = $docblock->getTagsByName('param');
135
-        foreach ($params as $param) 
136
-        {
137
-            $name = $param->getVariableName();
138
-            if ($name !== 'request') 
139
-            {
140
-                $route['parametars'][$param->getVariableName()] = $param->getDescription()->render();
141
-            }
142
-        }
143
-    }
121
+	/**
122
+	 * Generate description and params for the given route
123
+	 * based on the docblock.
124
+	 * 
125
+	 * @param  array  &$route
126
+	 * @param  object $reflectionMethod]
127
+	 * @return void
128
+	 */
129
+	protected function processDocBlock(&$route, $reflectionMethod)
130
+	{
131
+		$factory              = \phpDocumentor\Reflection\DocBlockFactory::createInstance();
132
+		$docblock             = $factory->create($reflectionMethod->getDocComment());
133
+		$route['description'] = trim(preg_replace('/\s+/', ' ', $docblock->getSummary()));
134
+		$params               = $docblock->getTagsByName('param');
135
+		foreach ($params as $param) 
136
+		{
137
+			$name = $param->getVariableName();
138
+			if ($name !== 'request') 
139
+			{
140
+				$route['parametars'][$param->getVariableName()] = $param->getDescription()->render();
141
+			}
142
+		}
143
+	}
144 144
 
145
-    /**
146
-     * Generate post body for the given route.
147
-     * 
148
-     * @param  array  &$route
149
-     * @param  object $reflectionMethod
150
-     * @param  array  $validationRules
151
-     * @return void
152
-     */
153
-    protected function getPostData(&$route, $reflectionMethod, $validationRules)
154
-    {
155
-        if ($route['method'] == 'POST') 
156
-        {
157
-            $body = $this->getMethodBody($reflectionMethod);
145
+	/**
146
+	 * Generate post body for the given route.
147
+	 * 
148
+	 * @param  array  &$route
149
+	 * @param  object $reflectionMethod
150
+	 * @param  array  $validationRules
151
+	 * @return void
152
+	 */
153
+	protected function getPostData(&$route, $reflectionMethod, $validationRules)
154
+	{
155
+		if ($route['method'] == 'POST') 
156
+		{
157
+			$body = $this->getMethodBody($reflectionMethod);
158 158
 
159
-            preg_match('/\$this->validate\(\$request,([^#]+)\);/iU', $body, $match);
160
-            if (count($match)) 
161
-            {
162
-                if ($match[1] == '$this->validationRules')
163
-                {
164
-                    $route['body'] = $validationRules;
165
-                }
166
-                else
167
-                {
168
-                    $route['body'] = eval('return ' . $match[1] . ';');
169
-                }
159
+			preg_match('/\$this->validate\(\$request,([^#]+)\);/iU', $body, $match);
160
+			if (count($match)) 
161
+			{
162
+				if ($match[1] == '$this->validationRules')
163
+				{
164
+					$route['body'] = $validationRules;
165
+				}
166
+				else
167
+				{
168
+					$route['body'] = eval('return ' . $match[1] . ';');
169
+				}
170 170
 
171
-                foreach ($route['body'] as &$rule) 
172
-                {
173
-                    if(strpos($rule, 'unique'))
174
-                    {
175
-                        $rule = substr($rule, 0, strpos($rule, 'unique') + 6);
176
-                    }
177
-                    elseif(strpos($rule, 'exists'))
178
-                    {
179
-                        $rule = substr($rule, 0, strpos($rule, 'exists') - 1);
180
-                    }
181
-                }
182
-            }
183
-            else
184
-            {
185
-                $route['body'] = 'conditions';
186
-            }
187
-        }
188
-    }
171
+				foreach ($route['body'] as &$rule) 
172
+				{
173
+					if(strpos($rule, 'unique'))
174
+					{
175
+						$rule = substr($rule, 0, strpos($rule, 'unique') + 6);
176
+					}
177
+					elseif(strpos($rule, 'exists'))
178
+					{
179
+						$rule = substr($rule, 0, strpos($rule, 'exists') - 1);
180
+					}
181
+				}
182
+			}
183
+			else
184
+			{
185
+				$route['body'] = 'conditions';
186
+			}
187
+		}
188
+	}
189 189
 
190
-    /**
191
-     * Generate application errors.
192
-     * 
193
-     * @return array
194
-     */
195
-    protected function getErrors()
196
-    {
197
-        $errors          = [];
198
-        $reflectionClass = new \ReflectionClass('App\Modules\V1\Core\Utl\ErrorHandler');
199
-        foreach ($reflectionClass->getMethods() as $method) 
200
-        {
201
-            $methodName       = $method->getName();
202
-            $reflectionMethod = $reflectionClass->getMethod($methodName);
203
-            $body             = $this->getMethodBody($reflectionMethod);
190
+	/**
191
+	 * Generate application errors.
192
+	 * 
193
+	 * @return array
194
+	 */
195
+	protected function getErrors()
196
+	{
197
+		$errors          = [];
198
+		$reflectionClass = new \ReflectionClass('App\Modules\V1\Core\Utl\ErrorHandler');
199
+		foreach ($reflectionClass->getMethods() as $method) 
200
+		{
201
+			$methodName       = $method->getName();
202
+			$reflectionMethod = $reflectionClass->getMethod($methodName);
203
+			$body             = $this->getMethodBody($reflectionMethod);
204 204
 
205
-            preg_match('/\$error=\[\'status\'=>([^#]+)\,/iU', $body, $match);
205
+			preg_match('/\$error=\[\'status\'=>([^#]+)\,/iU', $body, $match);
206 206
 
207
-            if (count($match)) 
208
-            {
209
-                $errors[$match[1]][] = $methodName;
210
-            }
211
-        }
207
+			if (count($match)) 
208
+			{
209
+				$errors[$match[1]][] = $methodName;
210
+			}
211
+		}
212 212
 
213
-        return $errors;
214
-    }
213
+		return $errors;
214
+	}
215 215
 
216
-    /**
217
-     * Get the given method body code.
218
-     * 
219
-     * @param  object $reflectionMethod
220
-     * @return string
221
-     */
222
-    protected function getMethodBody($reflectionMethod)
223
-    {
224
-        $filename   = $reflectionMethod->getFileName();
225
-        $start_line = $reflectionMethod->getStartLine() - 1;
226
-        $end_line   = $reflectionMethod->getEndLine();
227
-        $length     = $end_line - $start_line;         
228
-        $source     = file($filename);
229
-        $body       = implode("", array_slice($source, $start_line, $length));
230
-        $body       = trim(preg_replace('/\s+/', '', $body));
216
+	/**
217
+	 * Get the given method body code.
218
+	 * 
219
+	 * @param  object $reflectionMethod
220
+	 * @return string
221
+	 */
222
+	protected function getMethodBody($reflectionMethod)
223
+	{
224
+		$filename   = $reflectionMethod->getFileName();
225
+		$start_line = $reflectionMethod->getStartLine() - 1;
226
+		$end_line   = $reflectionMethod->getEndLine();
227
+		$length     = $end_line - $start_line;         
228
+		$source     = file($filename);
229
+		$body       = implode("", array_slice($source, $start_line, $length));
230
+		$body       = trim(preg_replace('/\s+/', '', $body));
231 231
 
232
-        return $body;
233
-    }
232
+		return $body;
233
+	}
234 234
 
235
-    /**
236
-     * Get example object of all availble models.
237
-     * 
238
-     * @param  string $modelName
239
-     * @param  object $docData
240
-     * @return string
241
-     */
242
-    protected function getModels($modelName, &$docData)
243
-    {
244
-        if ( ! array_key_exists($modelName, $docData['models'])) 
245
-        {
246
-            $modelClass      = call_user_func_array("\Core::{$modelName}", [])->model;
247
-            $model           = factory($modelClass)->make();
248
-            $docData['models'][$modelName] = json_encode($model->toArray(), JSON_PRETTY_PRINT);
249
-        }
250
-    }
235
+	/**
236
+	 * Get example object of all availble models.
237
+	 * 
238
+	 * @param  string $modelName
239
+	 * @param  object $docData
240
+	 * @return string
241
+	 */
242
+	protected function getModels($modelName, &$docData)
243
+	{
244
+		if ( ! array_key_exists($modelName, $docData['models'])) 
245
+		{
246
+			$modelClass      = call_user_func_array("\Core::{$modelName}", [])->model;
247
+			$model           = factory($modelClass)->make();
248
+			$docData['models'][$modelName] = json_encode($model->toArray(), JSON_PRETTY_PRINT);
249
+		}
250
+	}
251 251
 
252
-    /**
253
-     * Get the route response object type.
254
-     * 
255
-     * @param  string $method
256
-     * @param  string $route
257
-     * @return array
258
-     */
259
-    protected function getResponseObject($modelName, $method)
260
-    {
261
-        $config    = \CoreConfig::getConfig();
262
-        $relations = array_key_exists($modelName, $config['relations']) ? array_key_exists($method, $config['relations'][$modelName]) ? $config['relations'][$modelName] : false : false;
252
+	/**
253
+	 * Get the route response object type.
254
+	 * 
255
+	 * @param  string $method
256
+	 * @param  string $route
257
+	 * @return array
258
+	 */
259
+	protected function getResponseObject($modelName, $method)
260
+	{
261
+		$config    = \CoreConfig::getConfig();
262
+		$relations = array_key_exists($modelName, $config['relations']) ? array_key_exists($method, $config['relations'][$modelName]) ? $config['relations'][$modelName] : false : false;
263 263
 
264
-        return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false;
265
-    }
264
+		return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false;
265
+	}
266 266
 }
Please login to merge, or discard this patch.