@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('oauth_auth_codes', function (Blueprint $table) { |
|
16 | + Schema::create('oauth_auth_codes', function(Blueprint $table) { |
|
17 | 17 | $table->string('id', 100)->primary(); |
18 | 18 | $table->integer('user_id'); |
19 | 19 | $table->integer('client_id'); |
@@ -63,11 +63,11 @@ 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 | - $column = 'LOWER(' . array_shift($conditionColumns) . ')'; |
|
70 | + $column = 'LOWER('.array_shift($conditionColumns).')'; |
|
71 | 71 | if (str_contains($column, '->')) |
72 | 72 | { |
73 | 73 | $column = $this->wrapJsonSelector($column); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | /** |
77 | 77 | * Use the first element in the model columns to construct the first condition. |
78 | 78 | */ |
79 | - $q->where(\DB::raw($column), 'LIKE', '%' . strtolower($query) . '%'); |
|
79 | + $q->where(\DB::raw($column), 'LIKE', '%'.strtolower($query).'%'); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | */ |
85 | 85 | foreach ($conditionColumns as $column) |
86 | 86 | { |
87 | - $column = 'LOWER(' . $column . ')'; |
|
87 | + $column = 'LOWER('.$column.')'; |
|
88 | 88 | if (str_contains($column, '->')) |
89 | 89 | { |
90 | 90 | $column = $this->wrapJsonSelector($column); |
91 | 91 | } |
92 | 92 | |
93 | - $q->orWhere(\DB::raw($column), 'LIKE', '%' . strtolower($query) . '%'); |
|
93 | + $q->orWhere(\DB::raw($column), 'LIKE', '%'.strtolower($query).'%'); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | /** |
112 | 112 | * Construct the relation condition. |
113 | 113 | */ |
114 | - $q->orWhereHas($relation, function ($subModel) use ($query, $relation){ |
|
114 | + $q->orWhereHas($relation, function($subModel) use ($query, $relation){ |
|
115 | 115 | |
116 | - $subModel->where(function ($q) use ($query, $relation){ |
|
116 | + $subModel->where(function($q) use ($query, $relation){ |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Get columns of the relation. |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | if (count($subConditionColumns)) |
124 | 124 | { |
125 | 125 | |
126 | - $column = 'LOWER(' . array_shift($subConditionColumns) . ')'; |
|
126 | + $column = 'LOWER('.array_shift($subConditionColumns).')'; |
|
127 | 127 | if (str_contains($column, '->')) |
128 | 128 | { |
129 | 129 | $column = $this->wrapJsonSelector($column); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | /** |
133 | 133 | * Use the first element in the relation model columns to construct the first condition. |
134 | 134 | */ |
135 | - $q->where(\DB::raw($column), 'LIKE', '%' . strtolower($query) . '%'); |
|
135 | + $q->where(\DB::raw($column), 'LIKE', '%'.strtolower($query).'%'); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | */ |
141 | 141 | foreach ($subConditionColumns as $subConditionColumn) |
142 | 142 | { |
143 | - $column = 'LOWER(' . $subConditionColumn . ')'; |
|
143 | + $column = 'LOWER('.$subConditionColumn.')'; |
|
144 | 144 | if (str_contains($column, '->')) |
145 | 145 | { |
146 | 146 | $column = $this->wrapJsonSelector($column); |
147 | 147 | } |
148 | 148 | |
149 | - $q->orWhere(\DB::raw($column), 'LIKE', '%' . strtolower($query) . '%'); |
|
149 | + $q->orWhere(\DB::raw($column), 'LIKE', '%'.strtolower($query).'%'); |
|
150 | 150 | } |
151 | 151 | }); |
152 | 152 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $modelClass = $this->model; |
207 | 207 | $relations = []; |
208 | 208 | |
209 | - \DB::transaction(function () use (&$model, &$relations, $data, $modelClass) { |
|
209 | + \DB::transaction(function() use (&$model, &$relations, $data, $modelClass) { |
|
210 | 210 | /** |
211 | 211 | * If the id is present in the data then select the model for updating, |
212 | 212 | * else create new model. |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $model = array_key_exists('id', $data) ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass; |
216 | 216 | if ( ! $model) |
217 | 217 | { |
218 | - \ErrorHandler::notFound(class_basename($modelClass) . ' with id : ' . $data['id']); |
|
218 | + \ErrorHandler::notFound(class_basename($modelClass).' with id : '.$data['id']); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | */ |
274 | 274 | if ( ! $relationModel) |
275 | 275 | { |
276 | - \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $val['id']); |
|
276 | + \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$val['id']); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | /** |
285 | 285 | * Prevent the sub relations or attributes not in the fillable. |
286 | 286 | */ |
287 | - if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false) |
|
287 | + if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false) |
|
288 | 288 | { |
289 | 289 | $relationModel->$attr = $val; |
290 | 290 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | */ |
315 | 315 | if ( ! $relationModel) |
316 | 316 | { |
317 | - \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $value['id']); |
|
317 | + \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$value['id']); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | foreach ($value as $relationAttribute => $relationValue) |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | } |
457 | 457 | else |
458 | 458 | { |
459 | - call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data){ |
|
459 | + call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) use ($data){ |
|
460 | 460 | $model->update($data); |
461 | 461 | }); |
462 | 462 | } |
@@ -474,11 +474,11 @@ discard block |
||
474 | 474 | { |
475 | 475 | if ($attribute == 'id') |
476 | 476 | { |
477 | - \DB::transaction(function () use ($value, $attribute, &$result) { |
|
477 | + \DB::transaction(function() use ($value, $attribute, &$result) { |
|
478 | 478 | $model = $this->model->lockForUpdate()->find($value); |
479 | 479 | if ( ! $model) |
480 | 480 | { |
481 | - \ErrorHandler::notFound(class_basename($this->model) . ' with id : ' . $value); |
|
481 | + \ErrorHandler::notFound(class_basename($this->model).' with id : '.$value); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | $model->delete(); |
@@ -486,8 +486,8 @@ discard block |
||
486 | 486 | } |
487 | 487 | else |
488 | 488 | { |
489 | - \DB::transaction(function () use ($value, $attribute, &$result) { |
|
490 | - call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model){ |
|
489 | + \DB::transaction(function() use ($value, $attribute, &$result) { |
|
490 | + call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) { |
|
491 | 491 | $model->delete(); |
492 | 492 | }); |
493 | 493 | }); |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | { |
524 | 524 | $conditions = $this->constructConditions($conditions, $this->model); |
525 | 525 | $sort = $desc ? 'desc' : 'asc'; |
526 | - return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns); |
|
526 | + return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | /** |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
564 | 564 | } |
565 | 565 | |
566 | - return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns);; |
|
566 | + return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns); ; |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | /** |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | |
579 | 579 | if ( ! $model) |
580 | 580 | { |
581 | - \ErrorHandler::notFound(class_basename($this->model) . ' with id : ' . $id); |
|
581 | + \ErrorHandler::notFound(class_basename($this->model).' with id : '.$id); |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | $model->restore(); |
@@ -603,13 +603,13 @@ discard block |
||
603 | 603 | if ($key == 'and') |
604 | 604 | { |
605 | 605 | $conditions = $this->constructConditions($value, $model); |
606 | - $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']) . ' {op} '; |
|
606 | + $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']).' {op} '; |
|
607 | 607 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
608 | 608 | } |
609 | 609 | else if ($key == 'or') |
610 | 610 | { |
611 | 611 | $conditions = $this->constructConditions($value, $model); |
612 | - $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']) . ' {op} '; |
|
612 | + $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']).' {op} '; |
|
613 | 613 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
614 | 614 | } |
615 | 615 | else |
@@ -634,41 +634,41 @@ discard block |
||
634 | 634 | |
635 | 635 | if (strtolower($operator) == 'between') |
636 | 636 | { |
637 | - $conditionString .= $key . ' >= ? and '; |
|
637 | + $conditionString .= $key.' >= ? and '; |
|
638 | 638 | $conditionValues[] = $value1; |
639 | 639 | |
640 | - $conditionString .= $key . ' <= ? {op} '; |
|
640 | + $conditionString .= $key.' <= ? {op} '; |
|
641 | 641 | $conditionValues[] = $value2; |
642 | 642 | } |
643 | 643 | elseif (strtolower($operator) == 'in') |
644 | 644 | { |
645 | 645 | $conditionValues = array_merge($conditionValues, $value); |
646 | 646 | $inBindingsString = rtrim(str_repeat('?,', count($value)), ','); |
647 | - $conditionString .= $key . ' in (' . rtrim($inBindingsString, ',') . ') {op} '; |
|
647 | + $conditionString .= $key.' in ('.rtrim($inBindingsString, ',').') {op} '; |
|
648 | 648 | } |
649 | 649 | elseif (strtolower($operator) == 'null') |
650 | 650 | { |
651 | - $conditionString .= $key . ' is null {op} '; |
|
651 | + $conditionString .= $key.' is null {op} '; |
|
652 | 652 | } |
653 | 653 | elseif (strtolower($operator) == 'not null') |
654 | 654 | { |
655 | - $conditionString .= $key . ' is not null {op} '; |
|
655 | + $conditionString .= $key.' is not null {op} '; |
|
656 | 656 | } |
657 | 657 | elseif (strtolower($operator) == 'has') |
658 | 658 | { |
659 | 659 | $sql = $model->withTrashed()->has($key)->toSql(); |
660 | 660 | $conditions = $this->constructConditions($value, $model->$key()->getRelated()); |
661 | - $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')') . ' and ' . $conditions['conditionString'] . ') {op} '; |
|
661 | + $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')').' and '.$conditions['conditionString'].') {op} '; |
|
662 | 662 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
663 | 663 | } |
664 | 664 | else |
665 | 665 | { |
666 | - $conditionString .= $key . ' ' . $operator . ' ? {op} '; |
|
666 | + $conditionString .= $key.' '.$operator.' ? {op} '; |
|
667 | 667 | $conditionValues[] = $value; |
668 | 668 | } |
669 | 669 | } |
670 | 670 | } |
671 | - $conditionString = '(' . rtrim($conditionString, '{op} ') . ')'; |
|
671 | + $conditionString = '('.rtrim($conditionString, '{op} ').')'; |
|
672 | 672 | return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues]; |
673 | 673 | } |
674 | 674 | |
@@ -684,11 +684,11 @@ discard block |
||
684 | 684 | $value = $removeLast === false ? $value : substr($value, 0, $removeLast); |
685 | 685 | $path = explode('->', $value); |
686 | 686 | $field = array_shift($path); |
687 | - $result = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) { |
|
687 | + $result = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function($part) { |
|
688 | 688 | return '"'.$part.'"'; |
689 | 689 | })->implode('.')); |
690 | 690 | |
691 | - return $removeLast === false ? $result : $result . ')'; |
|
691 | + return $removeLast === false ? $result : $result.')'; |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | /** |
@@ -18,7 +18,7 @@ |
||
18 | 18 | /** |
19 | 19 | * Assign the permissions to the admin group. |
20 | 20 | */ |
21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['settings'])->each(function ($permission) use ($adminGroupId) { |
|
21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['settings'])->each(function($permission) use ($adminGroupId) { |
|
22 | 22 | \DB::table('groups_permissions')->insert( |
23 | 23 | [ |
24 | 24 | 'permission_id' => $permission->id, |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * to preform actions like (add, edit ... etc). |
13 | 13 | * @var string |
14 | 14 | */ |
15 | - protected $model = 'pushNotificationDevices'; |
|
15 | + protected $model = 'pushNotificationDevices'; |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * List of all route actions that the base api controller |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * to check before add. |
27 | 27 | * @var array |
28 | 28 | */ |
29 | - protected $validationRules = [ |
|
29 | + protected $validationRules = [ |
|
30 | 30 | 'device_token' => 'required|string|max:255', |
31 | 31 | 'user_id' => 'required|exists:users,id' |
32 | 32 | ]; |
@@ -12,7 +12,7 @@ |
||
12 | 12 | * to preform actions like (add, edit ... etc). |
13 | 13 | * @var string |
14 | 14 | */ |
15 | - protected $model = 'notifications'; |
|
15 | + protected $model = 'notifications'; |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * List of all route actions that the base api controller |
@@ -70,7 +70,7 @@ |
||
70 | 70 | */ |
71 | 71 | public function notify($users, $notification, $notificationData = false) |
72 | 72 | { |
73 | - $notification = 'App\Modules\V1\Notifications\Notifications\\' . $notification; |
|
73 | + $notification = 'App\Modules\V1\Notifications\Notifications\\'.$notification; |
|
74 | 74 | \Notification::send($users, new $notification($notificationData)); |
75 | 75 | } |
76 | 76 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | $notificationBuilder = new PayloadNotificationBuilder($title); |
50 | 50 | $dataBuilder = new PayloadDataBuilder(); |
51 | 51 | |
52 | - $optionBuilder->setTimeToLive(60*20); |
|
52 | + $optionBuilder->setTimeToLive(60 * 20); |
|
53 | 53 | $notificationBuilder->setBody($message); |
54 | 54 | $dataBuilder->addData($data); |
55 | 55 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$factory->define(App\Modules\V1\Notifications\Notification::class, function (Faker\Generator $faker) { |
|
3 | +$factory->define(App\Modules\V1\Notifications\Notification::class, function(Faker\Generator $faker) { |
|
4 | 4 | return [ |
5 | 5 | 'type' => '', |
6 | 6 | 'notifiable_type' => '', |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('notifications', function (Blueprint $table) { |
|
16 | + Schema::create('notifications', function(Blueprint $table) { |
|
17 | 17 | $table->uuid('id')->primary(); |
18 | 18 | $table->string('type'); |
19 | 19 | $table->morphs('notifiable'); |