@@ -26,7 +26,7 @@ |
||
26 | 26 | */ |
27 | 27 | public function revoke($clientId) |
28 | 28 | { |
29 | - \DB::transaction(function () use ($clientId) { |
|
29 | + \DB::transaction(function() use ($clientId) { |
|
30 | 30 | $client = $this->repo->find($clientId); |
31 | 31 | $this->repo->revokeClientTokens($client); |
32 | 32 | $this->repo->save(['id'=> $clientId, 'revoked' => true]); |
@@ -19,12 +19,12 @@ |
||
19 | 19 | public function __call($name, $arguments) |
20 | 20 | { |
21 | 21 | foreach (\Module::all() as $module) { |
22 | - $nameSpace = 'App\\Modules\\' . $module['basename'] ; |
|
22 | + $nameSpace = 'App\\Modules\\'.$module['basename']; |
|
23 | 23 | $model = ucfirst(\Str::singular($name)); |
24 | - if(count($arguments) == 1 && $arguments[0]) { |
|
25 | - $class = $nameSpace . '\\Services\\' . $model . 'Service'; |
|
24 | + if (count($arguments) == 1 && $arguments[0]) { |
|
25 | + $class = $nameSpace.'\\Services\\'.$model.'Service'; |
|
26 | 26 | } else { |
27 | - $class = $nameSpace . '\\Repositories\\' . $model . 'Repository'; |
|
27 | + $class = $nameSpace.'\\Repositories\\'.$model.'Repository'; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | if (class_exists($class)) { |
@@ -40,7 +40,7 @@ |
||
40 | 40 | return $values; |
41 | 41 | } |
42 | 42 | |
43 | - if (! $primaryLocale || ! is_object($values) || ! property_exists($values, $primaryLocale)) { |
|
43 | + if ( ! $primaryLocale || ! is_object($values) || ! property_exists($values, $primaryLocale)) { |
|
44 | 44 | return $values ? (isset($values->$fallbackLocale) ? $values->$fallbackLocale : $values) : ''; |
45 | 45 | } |
46 | 46 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function __construct($model) |
23 | 23 | { |
24 | - $this->model = $model; |
|
24 | + $this->model = $model; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $model = false; |
99 | 99 | $relations = []; |
100 | 100 | |
101 | - \DB::transaction(function () use (&$model, &$relations, $data) { |
|
101 | + \DB::transaction(function() use (&$model, &$relations, $data) { |
|
102 | 102 | |
103 | 103 | $model = $this->prepareModel($data); |
104 | 104 | $relations = $this->prepareRelations($data, $model); |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function delete($value, $attribute = 'id') |
124 | 124 | { |
125 | - \DB::transaction(function () use ($value, $attribute) { |
|
126 | - $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function ($model) { |
|
125 | + \DB::transaction(function() use ($value, $attribute) { |
|
126 | + $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function($model) { |
|
127 | 127 | $model->delete(); |
128 | 128 | }); |
129 | 129 | }); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | { |
214 | 214 | $model = $this->model->onlyTrashed()->find($id); |
215 | 215 | |
216 | - if (! $model) { |
|
216 | + if ( ! $model) { |
|
217 | 217 | \Errors::notFound(class_basename($this->model).' with id : '.$id); |
218 | 218 | } |
219 | 219 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @var array |
238 | 238 | */ |
239 | 239 | $model = Arr::has($data, 'id') ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass; |
240 | - if (! $model) { |
|
240 | + if ( ! $model) { |
|
241 | 241 | \Errors::notFound(class_basename($modelClass).' with id : '.$data['id']); |
242 | 242 | } |
243 | 243 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * If the relation has no value then marke the relation data |
295 | 295 | * related to the model to be deleted. |
296 | 296 | */ |
297 | - if (! $value || ! count($value)) { |
|
297 | + if ( ! $value || ! count($value)) { |
|
298 | 298 | $relations[$relation] = 'delete'; |
299 | 299 | } |
300 | 300 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * Check if the relation is a collection. |
313 | 313 | */ |
314 | 314 | if (class_basename($model->$relation) == 'Collection') { |
315 | - if (! is_array($val)) { |
|
315 | + if ( ! is_array($val)) { |
|
316 | 316 | $relationModel = $relationBaseModel->lockForUpdate()->find($val); |
317 | 317 | } else { |
318 | 318 | /** |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | /** |
326 | 326 | * If model doesn't exists. |
327 | 327 | */ |
328 | - if (! $relationModel) { |
|
328 | + if ( ! $relationModel) { |
|
329 | 329 | \Errors::notFound(class_basename($relationBaseModel).' with id : '.$val['id']); |
330 | 330 | } |
331 | 331 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | /** |
364 | 364 | * If model doesn't exists. |
365 | 365 | */ |
366 | - if (! $relationModel) { |
|
366 | + if ( ! $relationModel) { |
|
367 | 367 | \Errors::notFound(class_basename($relationBaseModel).' with id : '.$value['id']); |
368 | 368 | } |
369 | 369 | |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | $value = $removeLast === false ? $value : substr($value, 0, $removeLast); |
574 | 574 | $path = explode('->', $value); |
575 | 575 | $field = array_shift($path); |
576 | - $result = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) { |
|
576 | + $result = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function($part) { |
|
577 | 577 | return '"'.$part.'"'; |
578 | 578 | })->implode('.')); |
579 | 579 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | { |
38 | 38 | $translatable = $this->repo->model->translatable ?? []; |
39 | 39 | $filters = $this->constructFilters($conditions); |
40 | - $sortBy = in_array($sortBy, $translatable) ? $sortBy . '->' . \Session::get('locale') : $sortBy; |
|
40 | + $sortBy = in_array($sortBy, $translatable) ? $sortBy.'->'.\Session::get('locale') : $sortBy; |
|
41 | 41 | |
42 | 42 | if ($trashed) { |
43 | 43 | return $this->deleted(['and' => $filters], $perPage ?? 15, $sortBy ?? 'created_at', $desc ?? true); |
@@ -202,22 +202,22 @@ discard block |
||
202 | 202 | $translatable = $this->repo->model->translatable ?? []; |
203 | 203 | foreach ($conditions as $key => $value) { |
204 | 204 | if ((in_array($key, $this->repo->model->fillable ?? []) || method_exists($this->repo->model, $key) || in_array($key, ['or', 'and'])) && $key !== 'trashed') { |
205 | - $key = in_array($key, $translatable) ? $key . '->' . (\Session::get('locale') == 'all' ? 'en' : \Session::get('locale')) : $key; |
|
205 | + $key = in_array($key, $translatable) ? $key.'->'.(\Session::get('locale') == 'all' ? 'en' : \Session::get('locale')) : $key; |
|
206 | 206 | if (filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== null && strpos($key, '_id') === false && ! is_null($value)) { |
207 | 207 | $filters[$key] = filter_var($value, FILTER_VALIDATE_BOOLEAN); |
208 | - } elseif (! is_array($value) && strpos($key, '_id')) { |
|
208 | + } elseif ( ! is_array($value) && strpos($key, '_id')) { |
|
209 | 209 | $filters[$key] = [ |
210 | 210 | 'op' => 'in', |
211 | 211 | 'val' => explode(',', $value) |
212 | 212 | ]; |
213 | 213 | } elseif (is_array($value)) { |
214 | 214 | $filters[$key] = $value; |
215 | - } elseif($value) { |
|
216 | - $key = 'LOWER(' . $key . ')'; |
|
215 | + } elseif ($value) { |
|
216 | + $key = 'LOWER('.$key.')'; |
|
217 | 217 | $value = strtolower($value); |
218 | 218 | $filters[$key] = [ |
219 | 219 | 'op' => 'like', |
220 | - 'val' => '%' . $value . '%' |
|
220 | + 'val' => '%'.$value.'%' |
|
221 | 221 | ]; |
222 | 222 | } |
223 | 223 | } |