@@ -3,7 +3,7 @@ |
||
3 | 3 | use Illuminate\Database\Eloquent\Model; |
4 | 4 | use Illuminate\Database\Eloquent\SoftDeletes; |
5 | 5 | |
6 | -class PushNotificationDevice extends Model{ |
|
6 | +class PushNotificationDevice extends Model { |
|
7 | 7 | |
8 | 8 | use SoftDeletes; |
9 | 9 | protected $table = 'push_notifications_devices'; |
@@ -101,7 +101,7 @@ |
||
101 | 101 | */ |
102 | 102 | public function down() |
103 | 103 | { |
104 | - $permissions = DB::table('permissions')->whereIn('model', ['reports']); |
|
104 | + $permissions = DB::table('permissions')->whereIn('model', ['reports']); |
|
105 | 105 | DB::table('groups_permissions')->whereIn('permission_id', $permissions->lists('id'))->delete(); |
106 | 106 | $permissions->delete(); |
107 | 107 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | |
33 | 33 | if (array_key_exists('ios', $devicesArray)) |
34 | 34 | { |
35 | - $message = $this->constructMessage($messageText, [ 'badge' => 15, 'sound' => 'default', 'content-available' => 1 ]); |
|
35 | + $message = $this->constructMessage($messageText, ['badge' => 15, 'sound' => 'default', 'content-available' => 1]); |
|
36 | 36 | $iosDevices = \PushNotification::DeviceCollection($devicesArray['ios']); |
37 | 37 | $this->push('ios', $iosDevices, $message); |
38 | 38 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use Illuminate\Database\Eloquent\Model; |
4 | 4 | use Illuminate\Database\Eloquent\SoftDeletes; |
5 | 5 | |
6 | -class Report extends Model{ |
|
6 | +class Report extends Model { |
|
7 | 7 | |
8 | 8 | use SoftDeletes; |
9 | 9 | protected $table = 'reports'; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | protected $hidden = ['deleted_at']; |
12 | 12 | protected $guarded = ['id']; |
13 | 13 | protected $fillable = ['report_name', 'view_name']; |
14 | - public $searchable = ['report_name', 'view_name']; |
|
14 | + public $searchable = ['report_name', 'view_name']; |
|
15 | 15 | |
16 | 16 | public function getCreatedAtAttribute($value) |
17 | 17 | { |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * to preform actions like (add, edit ... etc). |
13 | 13 | * @var string |
14 | 14 | */ |
15 | - protected $model = 'users'; |
|
15 | + protected $model = 'users'; |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * List of all route actions that the base api controller |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | * will skip login check for them. |
27 | 27 | * @var array |
28 | 28 | */ |
29 | - protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword']; |
|
29 | + protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword']; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * The validations rules used by the base api controller |
33 | 33 | * to check before add. |
34 | 34 | * @var array |
35 | 35 | */ |
36 | - protected $validationRules = [ |
|
36 | + protected $validationRules = [ |
|
37 | 37 | 'email' => 'required|email|unique:users,email,{id}', |
38 | 38 | 'password' => 'min:6' |
39 | 39 | ]; |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | * @param boolean $user |
24 | 24 | * @return boolean |
25 | 25 | */ |
26 | - public function can($nameOfPermission, $model, $user = false ) |
|
26 | + public function can($nameOfPermission, $model, $user = false) |
|
27 | 27 | { |
28 | 28 | $user = $user ?: \JWTAuth::parseToken()->authenticate(); |
29 | 29 | $permissions = []; |
30 | - $this->find($user->id, ['groups.permissions'])->groups->lists('permissions')->each(function ($permission) use (&$permissions, $model){ |
|
30 | + $this->find($user->id, ['groups.permissions'])->groups->lists('permissions')->each(function($permission) use (&$permissions, $model){ |
|
31 | 31 | $permissions = array_merge($permissions, $permission->where('model', $model)->lists('name')->toArray()); |
32 | 32 | }); |
33 | 33 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function assignGroups($user_id, $group_ids) |
57 | 57 | { |
58 | - \DB::transaction(function () use ($user_id, $group_ids) { |
|
58 | + \DB::transaction(function() use ($user_id, $group_ids) { |
|
59 | 59 | $user = $this->find($user_id); |
60 | 60 | $user->groups()->detach(); |
61 | 61 | $user->groups()->attach($group_ids); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $view->with(['url' => $url]); |
223 | 223 | }); |
224 | 224 | |
225 | - $response = \Password::sendResetLink($email, function (\Illuminate\Mail\Message $message) { |
|
225 | + $response = \Password::sendResetLink($email, function(\Illuminate\Mail\Message $message) { |
|
226 | 226 | $message->subject('Your Password Reset Link'); |
227 | 227 | }); |
228 | 228 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | public function resetPassword($credentials) |
243 | 243 | { |
244 | 244 | $token = false; |
245 | - $response = \Password::reset($credentials, function ($user, $password) use (&$token) { |
|
245 | + $response = \Password::reset($credentials, function($user, $password) use (&$token) { |
|
246 | 246 | $user->password = bcrypt($password); |
247 | 247 | $user->save(); |
248 | 248 |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * Construct the select conditions for the model. |
65 | 65 | */ |
66 | - $model->where(function ($q) use ($query, $conditionColumns, $relations){ |
|
66 | + $model->where(function($q) use ($query, $conditionColumns, $relations){ |
|
67 | 67 | |
68 | 68 | if (count($conditionColumns)) |
69 | 69 | { |
70 | 70 | /** |
71 | 71 | * Use the first element in the model columns to construct the first condition. |
72 | 72 | */ |
73 | - $q->where(\DB::raw('LOWER(' . array_shift($conditionColumns) . ')'), 'LIKE', '%' . strtolower($query) . '%'); |
|
73 | + $q->where(\DB::raw('LOWER('.array_shift($conditionColumns).')'), 'LIKE', '%'.strtolower($query).'%'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | foreach ($conditionColumns as $column) |
80 | 80 | { |
81 | - $q->orWhere(\DB::raw('LOWER(' . $column . ')'), 'LIKE', '%' . strtolower($query) . '%'); |
|
81 | + $q->orWhere(\DB::raw('LOWER('.$column.')'), 'LIKE', '%'.strtolower($query).'%'); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | /** |
100 | 100 | * Construct the relation condition. |
101 | 101 | */ |
102 | - $q->orWhereHas($relation, function ($subModel) use ($query, $relation){ |
|
102 | + $q->orWhereHas($relation, function($subModel) use ($query, $relation){ |
|
103 | 103 | |
104 | - $subModel->where(function ($q) use ($query, $relation){ |
|
104 | + $subModel->where(function($q) use ($query, $relation){ |
|
105 | 105 | |
106 | 106 | /** |
107 | 107 | * Get columns of the relation. |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | /** |
114 | 114 | * Use the first element in the relation model columns to construct the first condition. |
115 | 115 | */ |
116 | - $q->where(\DB::raw('LOWER(' . array_shift($subConditionColumns) . ')'), 'LIKE', '%' . strtolower($query) . '%'); |
|
116 | + $q->where(\DB::raw('LOWER('.array_shift($subConditionColumns).')'), 'LIKE', '%'.strtolower($query).'%'); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | foreach ($subConditionColumns as $subConditionColumn) |
123 | 123 | { |
124 | - $q->orWhere(\DB::raw('LOWER(' . $subConditionColumn . ')'), 'LIKE', '%' . strtolower($query) . '%'); |
|
124 | + $q->orWhere(\DB::raw('LOWER('.$subConditionColumn.')'), 'LIKE', '%'.strtolower($query).'%'); |
|
125 | 125 | } |
126 | 126 | }); |
127 | 127 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $modelClass = $this->model; |
183 | 183 | $relations = []; |
184 | 184 | |
185 | - \DB::transaction(function () use (&$model, &$relations, $data, $saveLog, $modelClass) { |
|
185 | + \DB::transaction(function() use (&$model, &$relations, $data, $saveLog, $modelClass) { |
|
186 | 186 | /** |
187 | 187 | * If the id is present in the data then select the model for updating, |
188 | 188 | * else create new model. |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $model = array_key_exists('id', $data) ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass; |
192 | 192 | if ( ! $model) |
193 | 193 | { |
194 | - \ErrorHandler::notFound(class_basename($modelClass) . ' with id : ' . $data['id']); |
|
194 | + \ErrorHandler::notFound(class_basename($modelClass).' with id : '.$data['id']); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | if ( ! $relationModel) |
252 | 252 | { |
253 | - \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $val['id']); |
|
253 | + \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$val['id']); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | /** |
262 | 262 | * Prevent the sub relations or attributes not in the fillable. |
263 | 263 | */ |
264 | - if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false) |
|
264 | + if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false) |
|
265 | 265 | { |
266 | 266 | $relationModel->$attr = $val; |
267 | 267 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | */ |
290 | 290 | if ( ! $relationModel) |
291 | 291 | { |
292 | - \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $value['id']); |
|
292 | + \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$value['id']); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | } |
434 | 434 | else |
435 | 435 | { |
436 | - call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data, $saveLog){ |
|
436 | + call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) use ($data, $saveLog){ |
|
437 | 437 | $model->update($data); |
438 | 438 | $saveLog ? $this->logs->saveLog('update', class_basename($this->model), $this->getModel(), $model->id, $model) : false; |
439 | 439 | }); |
@@ -452,11 +452,11 @@ discard block |
||
452 | 452 | { |
453 | 453 | if ($attribute == 'id') |
454 | 454 | { |
455 | - \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) { |
|
455 | + \DB::transaction(function() use ($value, $attribute, &$result, $saveLog) { |
|
456 | 456 | $model = $this->model->lockForUpdate()->find($value); |
457 | 457 | if ( ! $model) |
458 | 458 | { |
459 | - \ErrorHandler::notFound(class_basename($this->model) . ' with id : ' . $value); |
|
459 | + \ErrorHandler::notFound(class_basename($this->model).' with id : '.$value); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | $model->delete(); |
@@ -465,8 +465,8 @@ discard block |
||
465 | 465 | } |
466 | 466 | else |
467 | 467 | { |
468 | - \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) { |
|
469 | - call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model){ |
|
468 | + \DB::transaction(function() use ($value, $attribute, &$result, $saveLog) { |
|
469 | + call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) { |
|
470 | 470 | $model->delete(); |
471 | 471 | $saveLog ? \Logging::saveLog('delete', class_basename($this->model), $this->getModel(), $model->id, $model) : false; |
472 | 472 | }); |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | { |
504 | 504 | $conditions = $this->constructConditions($conditions); |
505 | 505 | $sort = $desc ? 'desc' : 'asc'; |
506 | - return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns); |
|
506 | + return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | /** |
@@ -534,21 +534,21 @@ discard block |
||
534 | 534 | { |
535 | 535 | if ($key == 'and') |
536 | 536 | { |
537 | - $conditionString .= str_replace('{op}', 'and', $this->constructConditions($value)['conditionString']) . ' {op} '; |
|
537 | + $conditionString .= str_replace('{op}', 'and', $this->constructConditions($value)['conditionString']).' {op} '; |
|
538 | 538 | $conditionValues = array_merge($conditionValues, $this->constructConditions($value)['conditionValues']); |
539 | 539 | } |
540 | 540 | else if ($key == 'or') |
541 | 541 | { |
542 | - $conditionString .= str_replace('{op}', 'or', $this->constructConditions($value)['conditionString']) . ' {op} '; |
|
542 | + $conditionString .= str_replace('{op}', 'or', $this->constructConditions($value)['conditionString']).' {op} '; |
|
543 | 543 | $conditionValues = array_merge($conditionValues, $this->constructConditions($value)['conditionValues']); |
544 | 544 | } |
545 | 545 | else |
546 | 546 | { |
547 | - $conditionString .= $key . '=? {op} '; |
|
547 | + $conditionString .= $key.'=? {op} '; |
|
548 | 548 | $conditionValues[] = $value; |
549 | 549 | } |
550 | 550 | } |
551 | - $conditionString = '(' . rtrim($conditionString, '{op} ') . ')'; |
|
551 | + $conditionString = '('.rtrim($conditionString, '{op} ').')'; |
|
552 | 552 | return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues]; |
553 | 553 | } |
554 | 554 |