@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | use Illuminate\Database\Eloquent\Model; |
| 4 | 4 | use Illuminate\Database\Eloquent\SoftDeletes; |
| 5 | 5 | |
| 6 | -class AclGroup extends Model{ |
|
| 6 | +class AclGroup extends Model { |
|
| 7 | 7 | |
| 8 | 8 | use SoftDeletes; |
| 9 | 9 | protected $table = 'groups'; |
@@ -29,12 +29,12 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | public function users() |
| 31 | 31 | { |
| 32 | - return $this->belongsToMany('\App\Modules\Acl\AclUser','users_groups','group_id','user_id')->whereNull('users_groups.deleted_at')->withTimestamps(); |
|
| 32 | + return $this->belongsToMany('\App\Modules\Acl\AclUser', 'users_groups', 'group_id', 'user_id')->whereNull('users_groups.deleted_at')->withTimestamps(); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function permissions() |
| 36 | 36 | { |
| 37 | - return $this->belongsToMany('\App\Modules\Acl\AclPermission','groups_permissions','group_id','permission_id')->whereNull('groups_permissions.deleted_at')->withTimestamps(); |
|
| 37 | + return $this->belongsToMany('\App\Modules\Acl\AclPermission', 'groups_permissions', 'group_id', 'permission_id')->whereNull('groups_permissions.deleted_at')->withTimestamps(); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public static function boot() |
@@ -13,14 +13,14 @@ |
||
| 13 | 13 | * to preform actions like (add, edit ... etc). |
| 14 | 14 | * @var string |
| 15 | 15 | */ |
| 16 | - protected $model = 'groups'; |
|
| 16 | + protected $model = 'groups'; |
|
| 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|string|max:100|unique:groups,name,{id}' |
| 25 | 25 | ]; |
| 26 | 26 | |
@@ -12,15 +12,15 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('permissions', function (Blueprint $table) { |
|
| 15 | + Schema::create('permissions', function(Blueprint $table) { |
|
| 16 | 16 | $table->increments('id'); |
| 17 | - $table->string('name',100); |
|
| 18 | - $table->string('model',100); |
|
| 17 | + $table->string('name', 100); |
|
| 18 | + $table->string('model', 100); |
|
| 19 | 19 | $table->softDeletes(); |
| 20 | 20 | $table->timestamps(); |
| 21 | 21 | $table->unique(array('name', 'model')); |
| 22 | 22 | }); |
| 23 | - Schema::create('groups_permissions', function (Blueprint $table) { |
|
| 23 | + Schema::create('groups_permissions', function(Blueprint $table) { |
|
| 24 | 24 | $table->increments('id'); |
| 25 | 25 | $table->integer('group_id'); |
| 26 | 26 | $table->integer('permission_id'); |
@@ -12,14 +12,14 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('groups', function (Blueprint $table) { |
|
| 15 | + Schema::create('groups', function(Blueprint $table) { |
|
| 16 | 16 | $table->increments('id'); |
| 17 | - $table->string('name',100)->unique(); |
|
| 17 | + $table->string('name', 100)->unique(); |
|
| 18 | 18 | $table->softDeletes(); |
| 19 | 19 | $table->timestamps(); |
| 20 | 20 | }); |
| 21 | 21 | |
| 22 | - Schema::create('users_groups', function (Blueprint $table) { |
|
| 22 | + Schema::create('users_groups', function(Blueprint $table) { |
|
| 23 | 23 | $table->increments('id'); |
| 24 | 24 | $table->integer('user_id'); |
| 25 | 25 | $table->integer('group_id'); |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | |
| 30 | 30 | public function groups() |
| 31 | 31 | { |
| 32 | - return $this->belongsToMany('\App\Modules\Acl\AclGroup','groups_permissions','permission_id','group_id')->whereNull('groups_permissions.deleted_at')->withTimestamps(); |
|
| 32 | + return $this->belongsToMany('\App\Modules\Acl\AclGroup', 'groups_permissions', 'permission_id', 'group_id')->whereNull('groups_permissions.deleted_at')->withTimestamps(); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public static function boot() |
@@ -12,10 +12,10 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('reports', function (Blueprint $table) { |
|
| 15 | + Schema::create('reports', function(Blueprint $table) { |
|
| 16 | 16 | $table->increments('id'); |
| 17 | - $table->string('report_name',100); |
|
| 18 | - $table->string('view_name',100); |
|
| 17 | + $table->string('report_name', 100); |
|
| 18 | + $table->string('view_name', 100); |
|
| 19 | 19 | $table->softDeletes(); |
| 20 | 20 | $table->timestamps(); |
| 21 | 21 | }); |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | /** |
| 62 | 62 | * Check if the logged in user has the given group. |
| 63 | 63 | * |
| 64 | - * @param string $groupName |
|
| 65 | - * @param integer $userId |
|
| 64 | + * @param integer $user |
|
| 65 | + * @param string[] $groups |
|
| 66 | 66 | * @return boolean |
| 67 | 67 | */ |
| 68 | 68 | public function hasGroup($groups, $user = false) |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * Reset the given user's password. |
| 245 | 245 | * |
| 246 | 246 | * @param array $credentials |
| 247 | - * @return array |
|
| 247 | + * @return string|null |
|
| 248 | 248 | */ |
| 249 | 249 | public function resetPassword($credentials) |
| 250 | 250 | { |
@@ -361,7 +361,6 @@ discard block |
||
| 361 | 361 | /** |
| 362 | 362 | * Save the given data to the logged in user. |
| 363 | 363 | * |
| 364 | - * @param array $credentials |
|
| 365 | 364 | * @return void |
| 366 | 365 | */ |
| 367 | 366 | public function saveProfile($data) |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $user = \Core::users()->find(\Auth::id(), $relations); |
| 29 | 29 | foreach ($user->groups()->get() as $group) |
| 30 | 30 | { |
| 31 | - $group->permissions->each(function ($permission) use (&$permissions){ |
|
| 31 | + $group->permissions->each(function($permission) use (&$permissions){ |
|
| 32 | 32 | $permissions[$permission->model][$permission->id] = $permission->name; |
| 33 | 33 | }); |
| 34 | 34 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $user = $user ?: $this->find(\Auth::id(), ['groups.permissions']); |
| 52 | 52 | $permissions = []; |
| 53 | 53 | |
| 54 | - $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){ |
|
| 54 | + $user->groups->pluck('permissions')->each(function($permission) use (&$permissions, $model){ |
|
| 55 | 55 | $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); |
| 56 | 56 | }); |
| 57 | 57 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function assignGroups($user_id, $group_ids) |
| 83 | 83 | { |
| 84 | - \DB::transaction(function () use ($user_id, $group_ids) { |
|
| 84 | + \DB::transaction(function() use ($user_id, $group_ids) { |
|
| 85 | 85 | $user = $this->find($user_id); |
| 86 | 86 | $user->groups()->detach(); |
| 87 | 87 | $user->groups()->attach($group_ids); |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | public function resetPassword($credentials) |
| 250 | 250 | { |
| 251 | - $response = \Password::reset($credentials, function ($user, $password) { |
|
| 251 | + $response = \Password::reset($credentials, function($user, $password) { |
|
| 252 | 252 | $user->password = $password; |
| 253 | 253 | $user->save(); |
| 254 | 254 | }); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @param array $relations |
| 34 | 34 | * @param string $sortBy |
| 35 | - * @param boolean $desc |
|
| 35 | + * @param integer $desc |
|
| 36 | 36 | * @param array $columns |
| 37 | 37 | * @return collection |
| 38 | 38 | */ |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @param integer $perPage |
| 51 | 51 | * @param array $relations |
| 52 | 52 | * @param string $sortBy |
| 53 | - * @param boolean $desc |
|
| 53 | + * @param integer $desc |
|
| 54 | 54 | * @param array $columns |
| 55 | 55 | * @return collection |
| 56 | 56 | */ |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * @param integer $perPage |
| 165 | 165 | * @param array $relations |
| 166 | 166 | * @param string $sortBy |
| 167 | - * @param boolean $desc |
|
| 167 | + * @param integer $desc |
|
| 168 | 168 | * @param array $columns |
| 169 | 169 | * @return collection |
| 170 | 170 | */ |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @param integer $perPage |
| 183 | 183 | * @param array $relations |
| 184 | 184 | * @param string $sortBy |
| 185 | - * @param boolean $desc |
|
| 185 | + * @param integer $desc |
|
| 186 | 186 | * @param array $columns |
| 187 | 187 | * @return collection |
| 188 | 188 | */ |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * Save the given model to the storage. |
| 199 | 199 | * |
| 200 | 200 | * @param array $data |
| 201 | - * @return object |
|
| 201 | + * @return boolean |
|
| 202 | 202 | */ |
| 203 | 203 | public function save(array $data) |
| 204 | 204 | { |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | * id. |
| 517 | 517 | * |
| 518 | 518 | * @param integer $id |
| 519 | - * @param array $relations |
|
| 519 | + * @param string[] $relations |
|
| 520 | 520 | * @param array $columns |
| 521 | 521 | * @return object |
| 522 | 522 | */ |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | * @param array $conditions array of conditions |
| 533 | 533 | * @param array $relations |
| 534 | 534 | * @param string $sortBy |
| 535 | - * @param boolean $desc |
|
| 535 | + * @param integer $desc |
|
| 536 | 536 | * @param array $columns |
| 537 | 537 | * @return collection |
| 538 | 538 | */ |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | * @param array $conditions array of conditions |
| 565 | 565 | * @param integer $perPage |
| 566 | 566 | * @param string $sortBy |
| 567 | - * @param boolean $desc |
|
| 567 | + * @param integer $desc |
|
| 568 | 568 | * @param array $columns |
| 569 | 569 | * @return collection |
| 570 | 570 | */ |
@@ -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 | /** |
@@ -123,6 +123,7 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @param array &$route |
| 125 | 125 | * @param object $reflectionMethod] |
| 126 | + * @param \ReflectionMethod $reflectionMethod |
|
| 126 | 127 | * @return void |
| 127 | 128 | */ |
| 128 | 129 | protected function processDocBlock(&$route, $reflectionMethod) |
@@ -145,7 +146,7 @@ discard block |
||
| 145 | 146 | * Generate post body for the given route. |
| 146 | 147 | * |
| 147 | 148 | * @param array &$route |
| 148 | - * @param object $reflectionMethod |
|
| 149 | + * @param \ReflectionMethod $reflectionMethod |
|
| 149 | 150 | * @param array $validationRules |
| 150 | 151 | * @return void |
| 151 | 152 | */ |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | if ($route) |
| 46 | 46 | { |
| 47 | 47 | $actoinArray = explode('@', $route['action']); |
| 48 | - if(array_get($actoinArray, 1, false)) |
|
| 48 | + if (array_get($actoinArray, 1, false)) |
|
| 49 | 49 | { |
| 50 | 50 | $controller = $actoinArray[0]; |
| 51 | 51 | $method = $actoinArray[1]; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $route['response'] = $this->getResponseObject($classProperties['model'], $route['name'], $route['returnDocBlock']); |
| 65 | 65 | |
| 66 | 66 | preg_match('/api\/([^#]+)\//iU', $route['uri'], $module); |
| 67 | - $docData['modules'][$module[1]][substr($route['prefix'], strlen('/api/' . $module[1] . '/') - 1)][] = $route; |
|
| 67 | + $docData['modules'][$module[1]][substr($route['prefix'], strlen('/api/'.$module[1].'/') - 1)][] = $route; |
|
| 68 | 68 | |
| 69 | 69 | $this->getModels($classProperties['model'], $docData); |
| 70 | 70 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | protected function getRoutes() |
| 84 | 84 | { |
| 85 | - return collect(\Route::getRoutes())->map(function ($route) { |
|
| 85 | + return collect(\Route::getRoutes())->map(function($route) { |
|
| 86 | 86 | if (strpos($route->uri(), 'api') !== false) |
| 87 | 87 | { |
| 88 | 88 | return [ |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | ]; |
| 115 | 115 | |
| 116 | 116 | |
| 117 | - if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) |
|
| 117 | + if ( ! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) |
|
| 118 | 118 | { |
| 119 | 119 | $route['headers']['Authorization'] = 'Bearer {token}'; |
| 120 | 120 | } |
@@ -168,16 +168,16 @@ discard block |
||
| 168 | 168 | } |
| 169 | 169 | else |
| 170 | 170 | { |
| 171 | - $route['body'] = eval('return ' . str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]) . ';'); |
|
| 171 | + $route['body'] = eval('return '.str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]).';'); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | foreach ($route['body'] as &$rule) |
| 175 | 175 | { |
| 176 | - if(strpos($rule, 'unique')) |
|
| 176 | + if (strpos($rule, 'unique')) |
|
| 177 | 177 | { |
| 178 | 178 | $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
| 179 | 179 | } |
| 180 | - elseif(strpos($rule, 'exists')) |
|
| 180 | + elseif (strpos($rule, 'exists')) |
|
| 181 | 181 | { |
| 182 | 182 | $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
| 183 | 183 | } |
@@ -250,10 +250,10 @@ discard block |
||
| 250 | 250 | $model = factory($modelClass)->make(); |
| 251 | 251 | $modelArr = $model->toArray(); |
| 252 | 252 | |
| 253 | - if ( $model->trans && ! $model->trans->count()) |
|
| 253 | + if ($model->trans && ! $model->trans->count()) |
|
| 254 | 254 | { |
| 255 | 255 | $modelArr['trans'] = [ |
| 256 | - 'en' => factory($modelClass . 'Translation')->make()->toArray() |
|
| 256 | + 'en' => factory($modelClass.'Translation')->make()->toArray() |
|
| 257 | 257 | ]; |
| 258 | 258 | } |
| 259 | 259 | |