@@ -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', 'refreshtoken']; |
|
29 | + protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken']; |
|
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 | 'user_name' => 'string|unique:users,user_name,{id}', |
38 | 38 | 'email' => 'required|email|unique:users,email,{id}', |
39 | 39 | 'password' => 'min:6' |
@@ -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 | /** |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | */ |
250 | 250 | if ( ! $relationModel) |
251 | 251 | { |
252 | - \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $val['id']); |
|
252 | + \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$val['id']); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | /** |
261 | 261 | * Prevent the sub relations or attributes not in the fillable. |
262 | 262 | */ |
263 | - if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false) |
|
263 | + if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false) |
|
264 | 264 | { |
265 | 265 | $relationModel->$attr = $val; |
266 | 266 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | */ |
291 | 291 | if ( ! $relationModel) |
292 | 292 | { |
293 | - \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $value['id']); |
|
293 | + \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$value['id']); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | foreach ($value as $relationAttribute => $relationValue) |
@@ -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 ? \Logging::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, $this->model); |
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 | /** |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
544 | 544 | } |
545 | 545 | |
546 | - return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns);; |
|
546 | + return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns); ; |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | /** |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | |
560 | 560 | if ( ! $model) |
561 | 561 | { |
562 | - \ErrorHandler::notFound(class_basename($this->model) . ' with id : ' . $id); |
|
562 | + \ErrorHandler::notFound(class_basename($this->model).' with id : '.$id); |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | $model->restore(); |
@@ -579,13 +579,13 @@ discard block |
||
579 | 579 | if ($key == 'and') |
580 | 580 | { |
581 | 581 | $conditions = $this->constructConditions($value, $model); |
582 | - $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']) . ' {op} '; |
|
582 | + $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']).' {op} '; |
|
583 | 583 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
584 | 584 | } |
585 | 585 | else if ($key == 'or') |
586 | 586 | { |
587 | 587 | $conditions = $this->constructConditions($value, $model); |
588 | - $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']) . ' {op} '; |
|
588 | + $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']).' {op} '; |
|
589 | 589 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
590 | 590 | } |
591 | 591 | else |
@@ -610,41 +610,41 @@ discard block |
||
610 | 610 | |
611 | 611 | if (strtolower($operator) == 'between') |
612 | 612 | { |
613 | - $conditionString .= $key . ' >= ? and '; |
|
613 | + $conditionString .= $key.' >= ? and '; |
|
614 | 614 | $conditionValues[] = $value1; |
615 | 615 | |
616 | - $conditionString .= $key . ' <= ? {op} '; |
|
616 | + $conditionString .= $key.' <= ? {op} '; |
|
617 | 617 | $conditionValues[] = $value2; |
618 | 618 | } |
619 | 619 | elseif (strtolower($operator) == 'in') |
620 | 620 | { |
621 | 621 | $conditionValues = array_merge($conditionValues, $value); |
622 | 622 | $inBindingsString = rtrim(str_repeat('?,', count($value)), ','); |
623 | - $conditionString .= $key . ' in (' . rtrim($inBindingsString, ',') . ') {op} '; |
|
623 | + $conditionString .= $key.' in ('.rtrim($inBindingsString, ',').') {op} '; |
|
624 | 624 | } |
625 | 625 | elseif (strtolower($operator) == 'null') |
626 | 626 | { |
627 | - $conditionString .= $key . ' is null {op} '; |
|
627 | + $conditionString .= $key.' is null {op} '; |
|
628 | 628 | } |
629 | 629 | elseif (strtolower($operator) == 'not null') |
630 | 630 | { |
631 | - $conditionString .= $key . ' is not null {op} '; |
|
631 | + $conditionString .= $key.' is not null {op} '; |
|
632 | 632 | } |
633 | 633 | elseif (strtolower($operator) == 'has') |
634 | 634 | { |
635 | 635 | $sql = $model->withTrashed()->has($key)->toSql(); |
636 | 636 | $conditions = $this->constructConditions($value, $model->first()->$key); |
637 | - $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')') . ' and ' . $conditions['conditionString'] . ')'; |
|
637 | + $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')').' and '.$conditions['conditionString'].')'; |
|
638 | 638 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
639 | 639 | } |
640 | 640 | else |
641 | 641 | { |
642 | - $conditionString .= $key . ' ' . $operator . ' ? {op} '; |
|
642 | + $conditionString .= $key.' '.$operator.' ? {op} '; |
|
643 | 643 | $conditionValues[] = $value; |
644 | 644 | } |
645 | 645 | } |
646 | 646 | } |
647 | - $conditionString = '(' . rtrim($conditionString, '{op} ') . ')'; |
|
647 | + $conditionString = '('.rtrim($conditionString, '{op} ').')'; |
|
648 | 648 | return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues]; |
649 | 649 | } |
650 | 650 |
@@ -54,7 +54,7 @@ |
||
54 | 54 | $this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : []; |
55 | 55 | $this->skipLoginCheck = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : []; |
56 | 56 | $this->relations = array_key_exists($this->model, $this->config['relations']) ? $this->config['relations'][$this->model] : false; |
57 | - $route = explode('@',\Route::currentRouteAction())[1]; |
|
57 | + $route = explode('@', \Route::currentRouteAction())[1]; |
|
58 | 58 | $this->checkPermission($route); |
59 | 59 | } |
60 | 60 |
@@ -12,7 +12,7 @@ |
||
12 | 12 | */ |
13 | 13 | public function up() |
14 | 14 | { |
15 | - Schema::create('push_notifications_devices', function (Blueprint $table) { |
|
15 | + Schema::create('push_notifications_devices', function(Blueprint $table) { |
|
16 | 16 | $table->increments('id'); |
17 | 17 | $table->string('device_token'); |
18 | 18 | $table->enum('device_type', ['android', 'ios']); |