@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$factory->define(App\Modules\Acl\AclGroup::class, function (Faker\Generator $faker) { |
|
| 3 | +$factory->define(App\Modules\Acl\AclGroup::class, function(Faker\Generator $faker) { |
|
| 4 | 4 | return [ |
| 5 | 5 | 'name' => $faker->unique->word(), |
| 6 | 6 | 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$factory->define(App\Modules\Acl\AclPermission::class, function (Faker\Generator $faker) { |
|
| 3 | +$factory->define(App\Modules\Acl\AclPermission::class, function(Faker\Generator $faker) { |
|
| 4 | 4 | return [ |
| 5 | 5 | 'name' => $faker->randomElement(['save', 'delete', 'find', 'paginate']), |
| 6 | 6 | 'model' => $faker->randomElement(['users', 'groups', 'settings', 'notifications']), |
@@ -13,14 +13,14 @@ |
||
| 13 | 13 | * to preform actions like (add, edit ... etc). |
| 14 | 14 | * @var string |
| 15 | 15 | */ |
| 16 | - protected $model = 'oauthClients'; |
|
| 16 | + protected $model = 'oauthClients'; |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * The validations rules used by the base api controller |
| 20 | 20 | * to check before add. |
| 21 | 21 | * @var array |
| 22 | 22 | */ |
| 23 | - protected $validationRules = [ |
|
| 23 | + protected $validationRules = [ |
|
| 24 | 24 | 'name' => 'required|max:255', |
| 25 | 25 | 'redirect' => 'required|url', |
| 26 | 26 | 'user_id' => 'required|exists:users,id', |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | public function assignPermissions($groupId, $permissionIds) |
| 25 | 25 | { |
| 26 | - \DB::transaction(function () use ($groupId, $permissionIds) { |
|
| 26 | + \DB::transaction(function() use ($groupId, $permissionIds) { |
|
| 27 | 27 | $group = $this->find($groupId); |
| 28 | 28 | $group->permissions()->detach(); |
| 29 | 29 | $group->permissions()->attach($permissionIds); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | Route::group([ |
| 55 | 55 | 'middleware' => 'web', |
| 56 | 56 | 'namespace' => $this->namespace, |
| 57 | - ], function ($router) { |
|
| 57 | + ], function($router) { |
|
| 58 | 58 | require module_path('core', 'Routes/web.php'); |
| 59 | 59 | }); |
| 60 | 60 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | 'middleware' => 'api', |
| 73 | 73 | 'namespace' => $this->namespace, |
| 74 | 74 | 'prefix' => 'api', |
| 75 | - ], function ($router) { |
|
| 75 | + ], function($router) { |
|
| 76 | 76 | require module_path('core', 'Routes/api.php'); |
| 77 | 77 | }); |
| 78 | 78 | } |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | if ($this->cacheConfig && $this->cacheConfig == 'cache') |
| 65 | 65 | { |
| 66 | 66 | $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
| 67 | - $cacheKey = $name . $page . \Session::get('locale') . serialize($arguments); |
|
| 67 | + $cacheKey = $name.$page.\Session::get('locale').serialize($arguments); |
|
| 68 | 68 | return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
| 69 | 69 | return call_user_func_array([$this->repo, $name], $arguments); |
| 70 | 70 | }); |
@@ -18,10 +18,10 @@ |
||
| 18 | 18 | { |
| 19 | 19 | foreach ($this->getRepoNameSpace() as $repoNameSpace) |
| 20 | 20 | { |
| 21 | - $class = rtrim($repoNameSpace, '\\') . '\\' . ucfirst(str_singular($name)) . 'Repository'; |
|
| 21 | + $class = rtrim($repoNameSpace, '\\').'\\'.ucfirst(str_singular($name)).'Repository'; |
|
| 22 | 22 | if (class_exists($class)) |
| 23 | 23 | { |
| 24 | - \App::singleton($class, function ($app) use ($class) { |
|
| 24 | + \App::singleton($class, function($app) use ($class) { |
|
| 25 | 25 | |
| 26 | 26 | return new \App\Modules\Core\Decorators\CachingDecorator(new $class, $app['cache.store']); |
| 27 | 27 | }); |
@@ -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 | /** |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | use App\Modules\Core\AbstractRepositories\AbstractRepositoryContainer; |
| 4 | 4 | |
| 5 | -class Core extends AbstractRepositoryContainer{ |
|
| 5 | +class Core extends AbstractRepositoryContainer { |
|
| 6 | 6 | /** |
| 7 | 7 | * Specify module repositories name space. |
| 8 | 8 | * |