@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | /** |
| 62 | 62 | * Check if the logged in user has the given group. |
| 63 | 63 | * |
| 64 | - * @param array $groups |
|
| 64 | + * @param string[] $groups |
|
| 65 | 65 | * @param mixed $user |
| 66 | 66 | * @return boolean |
| 67 | 67 | */ |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @param array $credentials |
| 157 | 157 | * @param boolean $skipConfirmEmail |
| 158 | - * @return array |
|
| 158 | + * @return boolean |
|
| 159 | 159 | */ |
| 160 | 160 | public function register($credentials, $skipConfirmEmail = false) |
| 161 | 161 | { |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | * Reset the given user's password. |
| 247 | 247 | * |
| 248 | 248 | * @param array $credentials |
| 249 | - * @return array |
|
| 249 | + * @return string|null |
|
| 250 | 250 | */ |
| 251 | 251 | public function resetPassword($credentials) |
| 252 | 252 | { |
@@ -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 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function assignGroups($userId, $groupIds) |
| 82 | 82 | { |
| 83 | - \DB::transaction(function () use ($userId, $groupIds) { |
|
| 83 | + \DB::transaction(function() use ($userId, $groupIds) { |
|
| 84 | 84 | $user = $this->find($userId); |
| 85 | 85 | $user->groups()->detach(); |
| 86 | 86 | $user->groups()->attach($groupIds); |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | public function resetPassword($credentials) |
| 252 | 252 | { |
| 253 | - $response = \Password::reset($credentials, function ($user, $password) { |
|
| 253 | + $response = \Password::reset($credentials, function($user, $password) { |
|
| 254 | 254 | $user->password = $password; |
| 255 | 255 | $user->save(); |
| 256 | 256 | }); |
@@ -102,20 +102,16 @@ discard block |
||
| 102 | 102 | if ( ! $user = $this->first(['email' => $credentials['email']])) |
| 103 | 103 | { |
| 104 | 104 | \ErrorHandler::loginFailed(); |
| 105 | - } |
|
| 106 | - else if ($adminLogin && ! $user->groups->whereIn('name', ['Admin'])->count()) |
|
| 105 | + } else if ($adminLogin && ! $user->groups->whereIn('name', ['Admin'])->count()) |
|
| 107 | 106 | { |
| 108 | 107 | \ErrorHandler::loginFailed(); |
| 109 | - } |
|
| 110 | - else if ( ! $adminLogin && $user->groups->whereIn('name', ['Admin'])->count()) |
|
| 108 | + } else if ( ! $adminLogin && $user->groups->whereIn('name', ['Admin'])->count()) |
|
| 111 | 109 | { |
| 112 | 110 | \ErrorHandler::loginFailed(); |
| 113 | - } |
|
| 114 | - else if ($user->blocked) |
|
| 111 | + } else if ($user->blocked) |
|
| 115 | 112 | { |
| 116 | 113 | \ErrorHandler::userIsBlocked(); |
| 117 | - } |
|
| 118 | - else if ( ! config('skeleton.disable_confirm_email') && ! $user->confirmed) |
|
| 114 | + } else if ( ! config('skeleton.disable_confirm_email') && ! $user->confirmed) |
|
| 119 | 115 | { |
| 120 | 116 | \ErrorHandler::emailNotConfirmed(); |
| 121 | 117 | } |
@@ -165,8 +161,7 @@ discard block |
||
| 165 | 161 | { |
| 166 | 162 | $user->confirmed = 1; |
| 167 | 163 | $user->save(); |
| 168 | - } |
|
| 169 | - else if ( ! config('skeleton.disable_confirm_email')) |
|
| 164 | + } else if ( ! config('skeleton.disable_confirm_email')) |
|
| 170 | 165 | { |
| 171 | 166 | $this->sendConfirmationEmail($user->email); |
| 172 | 167 | } |
@@ -189,12 +184,10 @@ discard block |
||
| 189 | 184 | if ( ! $this->hasGroup(['Admin'])) |
| 190 | 185 | { |
| 191 | 186 | \ErrorHandler::noPermissions(); |
| 192 | - } |
|
| 193 | - else if (\Auth::id() == $userId) |
|
| 187 | + } else if (\Auth::id() == $userId) |
|
| 194 | 188 | { |
| 195 | 189 | \ErrorHandler::noPermissions(); |
| 196 | - } |
|
| 197 | - else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
| 190 | + } else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
| 198 | 191 | { |
| 199 | 192 | \ErrorHandler::noPermissions(); |
| 200 | 193 | } |
@@ -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 mixed |
|
| 201 | + * @return boolean |
|
| 202 | 202 | */ |
| 203 | 203 | public function save(array $data) |
| 204 | 204 | { |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | * id. |
| 518 | 518 | * |
| 519 | 519 | * @param integer $id |
| 520 | - * @param array $relations |
|
| 520 | + * @param string[] $relations |
|
| 521 | 521 | * @param array $columns |
| 522 | 522 | * @return object |
| 523 | 523 | */ |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | * @param array $conditions array of conditions |
| 534 | 534 | * @param array $relations |
| 535 | 535 | * @param string $sortBy |
| 536 | - * @param boolean $desc |
|
| 536 | + * @param integer $desc |
|
| 537 | 537 | * @param array $columns |
| 538 | 538 | * @return collection |
| 539 | 539 | */ |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | * @param array $conditions array of conditions |
| 566 | 566 | * @param integer $perPage |
| 567 | 567 | * @param string $sortBy |
| 568 | - * @param boolean $desc |
|
| 568 | + * @param integer $desc |
|
| 569 | 569 | * @param array $columns |
| 570 | 570 | * @return collection |
| 571 | 571 | */ |
@@ -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 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $modelClass = $this->model; |
| 208 | 208 | $relations = []; |
| 209 | 209 | |
| 210 | - \DB::transaction(function () use (&$model, &$relations, $data, $modelClass) { |
|
| 210 | + \DB::transaction(function() use (&$model, &$relations, $data, $modelClass) { |
|
| 211 | 211 | /** |
| 212 | 212 | * If the id is present in the data then select the model for updating, |
| 213 | 213 | * else create new model. |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $model = array_key_exists('id', $data) ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass; |
| 217 | 217 | if ( ! $model) |
| 218 | 218 | { |
| 219 | - \ErrorHandler::notFound(class_basename($modelClass) . ' with id : ' . $data['id']); |
|
| 219 | + \ErrorHandler::notFound(class_basename($modelClass).' with id : '.$data['id']); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | */ |
| 275 | 275 | if ( ! $relationModel) |
| 276 | 276 | { |
| 277 | - \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $val['id']); |
|
| 277 | + \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$val['id']); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | /** |
| 286 | 286 | * Prevent the sub relations or attributes not in the fillable. |
| 287 | 287 | */ |
| 288 | - if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false) |
|
| 288 | + if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false) |
|
| 289 | 289 | { |
| 290 | 290 | $relationModel->$attr = $val; |
| 291 | 291 | } |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | */ |
| 316 | 316 | if ( ! $relationModel) |
| 317 | 317 | { |
| 318 | - \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $value['id']); |
|
| 318 | + \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$value['id']); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | foreach ($value as $relationAttribute => $relationValue) |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | } |
| 475 | 475 | else |
| 476 | 476 | { |
| 477 | - call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data){ |
|
| 477 | + call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) use ($data){ |
|
| 478 | 478 | $model->update($data); |
| 479 | 479 | }); |
| 480 | 480 | } |
@@ -492,11 +492,11 @@ discard block |
||
| 492 | 492 | { |
| 493 | 493 | if ($attribute == 'id') |
| 494 | 494 | { |
| 495 | - \DB::transaction(function () use ($value, $attribute, &$result) { |
|
| 495 | + \DB::transaction(function() use ($value, $attribute, &$result) { |
|
| 496 | 496 | $model = $this->model->lockForUpdate()->find($value); |
| 497 | 497 | if ( ! $model) |
| 498 | 498 | { |
| 499 | - \ErrorHandler::notFound(class_basename($this->model) . ' with id : ' . $value); |
|
| 499 | + \ErrorHandler::notFound(class_basename($this->model).' with id : '.$value); |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | $model->delete(); |
@@ -504,8 +504,8 @@ discard block |
||
| 504 | 504 | } |
| 505 | 505 | else |
| 506 | 506 | { |
| 507 | - \DB::transaction(function () use ($value, $attribute, &$result) { |
|
| 508 | - call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model){ |
|
| 507 | + \DB::transaction(function() use ($value, $attribute, &$result) { |
|
| 508 | + call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) { |
|
| 509 | 509 | $model->delete(); |
| 510 | 510 | }); |
| 511 | 511 | }); |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | { |
| 542 | 542 | $conditions = $this->constructConditions($conditions, $this->model); |
| 543 | 543 | $sort = $desc ? 'desc' : 'asc'; |
| 544 | - return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns); |
|
| 544 | + return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | /** |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns);; |
|
| 584 | + return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns); ; |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | /** |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | |
| 597 | 597 | if ( ! $model) |
| 598 | 598 | { |
| 599 | - \ErrorHandler::notFound(class_basename($this->model) . ' with id : ' . $id); |
|
| 599 | + \ErrorHandler::notFound(class_basename($this->model).' with id : '.$id); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | $model->restore(); |
@@ -621,13 +621,13 @@ discard block |
||
| 621 | 621 | if ($key == 'and') |
| 622 | 622 | { |
| 623 | 623 | $conditions = $this->constructConditions($value, $model); |
| 624 | - $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']) . ' {op} '; |
|
| 624 | + $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']).' {op} '; |
|
| 625 | 625 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 626 | 626 | } |
| 627 | 627 | else if ($key == 'or') |
| 628 | 628 | { |
| 629 | 629 | $conditions = $this->constructConditions($value, $model); |
| 630 | - $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']) . ' {op} '; |
|
| 630 | + $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']).' {op} '; |
|
| 631 | 631 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 632 | 632 | } |
| 633 | 633 | else |
@@ -652,41 +652,41 @@ discard block |
||
| 652 | 652 | |
| 653 | 653 | if (strtolower($operator) == 'between') |
| 654 | 654 | { |
| 655 | - $conditionString .= $key . ' >= ? and '; |
|
| 655 | + $conditionString .= $key.' >= ? and '; |
|
| 656 | 656 | $conditionValues[] = $value1; |
| 657 | 657 | |
| 658 | - $conditionString .= $key . ' <= ? {op} '; |
|
| 658 | + $conditionString .= $key.' <= ? {op} '; |
|
| 659 | 659 | $conditionValues[] = $value2; |
| 660 | 660 | } |
| 661 | 661 | elseif (strtolower($operator) == 'in') |
| 662 | 662 | { |
| 663 | 663 | $conditionValues = array_merge($conditionValues, $value); |
| 664 | 664 | $inBindingsString = rtrim(str_repeat('?,', count($value)), ','); |
| 665 | - $conditionString .= $key . ' in (' . rtrim($inBindingsString, ',') . ') {op} '; |
|
| 665 | + $conditionString .= $key.' in ('.rtrim($inBindingsString, ',').') {op} '; |
|
| 666 | 666 | } |
| 667 | 667 | elseif (strtolower($operator) == 'null') |
| 668 | 668 | { |
| 669 | - $conditionString .= $key . ' is null {op} '; |
|
| 669 | + $conditionString .= $key.' is null {op} '; |
|
| 670 | 670 | } |
| 671 | 671 | elseif (strtolower($operator) == 'not null') |
| 672 | 672 | { |
| 673 | - $conditionString .= $key . ' is not null {op} '; |
|
| 673 | + $conditionString .= $key.' is not null {op} '; |
|
| 674 | 674 | } |
| 675 | 675 | elseif (strtolower($operator) == 'has') |
| 676 | 676 | { |
| 677 | 677 | $sql = $model->withTrashed()->has($key)->toSql(); |
| 678 | 678 | $conditions = $this->constructConditions($value, $model->$key()->getRelated()); |
| 679 | - $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')') . ' and ' . $conditions['conditionString'] . ') {op} '; |
|
| 679 | + $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')').' and '.$conditions['conditionString'].') {op} '; |
|
| 680 | 680 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 681 | 681 | } |
| 682 | 682 | else |
| 683 | 683 | { |
| 684 | - $conditionString .= $key . ' ' . $operator . ' ? {op} '; |
|
| 684 | + $conditionString .= $key.' '.$operator.' ? {op} '; |
|
| 685 | 685 | $conditionValues[] = $value; |
| 686 | 686 | } |
| 687 | 687 | } |
| 688 | 688 | } |
| 689 | - $conditionString = '(' . rtrim($conditionString, '{op} ') . ')'; |
|
| 689 | + $conditionString = '('.rtrim($conditionString, '{op} ').')'; |
|
| 690 | 690 | return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues]; |
| 691 | 691 | } |
| 692 | 692 | |
@@ -702,11 +702,11 @@ discard block |
||
| 702 | 702 | $value = $removeLast === false ? $value : substr($value, 0, $removeLast); |
| 703 | 703 | $path = explode('->', $value); |
| 704 | 704 | $field = array_shift($path); |
| 705 | - $result = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) { |
|
| 705 | + $result = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function($part) { |
|
| 706 | 706 | return '"'.$part.'"'; |
| 707 | 707 | })->implode('.')); |
| 708 | 708 | |
| 709 | - return $removeLast === false ? $result : $result . ')'; |
|
| 709 | + return $removeLast === false ? $result : $result.')'; |
|
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | /** |
@@ -471,8 +471,7 @@ discard block |
||
| 471 | 471 | { |
| 472 | 472 | $model = $this->model->lockForUpdate()->find($value); |
| 473 | 473 | $model ? $model->update($data) : 0; |
| 474 | - } |
|
| 475 | - else |
|
| 474 | + } else |
|
| 476 | 475 | { |
| 477 | 476 | call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data){ |
| 478 | 477 | $model->update($data); |
@@ -501,8 +500,7 @@ discard block |
||
| 501 | 500 | |
| 502 | 501 | $model->delete(); |
| 503 | 502 | }); |
| 504 | - } |
|
| 505 | - else |
|
| 503 | + } else |
|
| 506 | 504 | { |
| 507 | 505 | \DB::transaction(function () use ($value, $attribute, &$result) { |
| 508 | 506 | call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model){ |
@@ -623,14 +621,12 @@ discard block |
||
| 623 | 621 | $conditions = $this->constructConditions($value, $model); |
| 624 | 622 | $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']) . ' {op} '; |
| 625 | 623 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 626 | - } |
|
| 627 | - else if ($key == 'or') |
|
| 624 | + } else if ($key == 'or') |
|
| 628 | 625 | { |
| 629 | 626 | $conditions = $this->constructConditions($value, $model); |
| 630 | 627 | $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']) . ' {op} '; |
| 631 | 628 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 632 | - } |
|
| 633 | - else |
|
| 629 | + } else |
|
| 634 | 630 | { |
| 635 | 631 | if (is_array($value)) |
| 636 | 632 | { |
@@ -639,13 +635,11 @@ discard block |
||
| 639 | 635 | { |
| 640 | 636 | $value1 = $value['val1']; |
| 641 | 637 | $value2 = $value['val2']; |
| 642 | - } |
|
| 643 | - else |
|
| 638 | + } else |
|
| 644 | 639 | { |
| 645 | 640 | $value = array_key_exists('val', $value) ? $value['val'] : ''; |
| 646 | 641 | } |
| 647 | - } |
|
| 648 | - else |
|
| 642 | + } else |
|
| 649 | 643 | { |
| 650 | 644 | $operator = '='; |
| 651 | 645 | } |
@@ -657,29 +651,24 @@ discard block |
||
| 657 | 651 | |
| 658 | 652 | $conditionString .= $key . ' <= ? {op} '; |
| 659 | 653 | $conditionValues[] = $value2; |
| 660 | - } |
|
| 661 | - elseif (strtolower($operator) == 'in') |
|
| 654 | + } elseif (strtolower($operator) == 'in') |
|
| 662 | 655 | { |
| 663 | 656 | $conditionValues = array_merge($conditionValues, $value); |
| 664 | 657 | $inBindingsString = rtrim(str_repeat('?,', count($value)), ','); |
| 665 | 658 | $conditionString .= $key . ' in (' . rtrim($inBindingsString, ',') . ') {op} '; |
| 666 | - } |
|
| 667 | - elseif (strtolower($operator) == 'null') |
|
| 659 | + } elseif (strtolower($operator) == 'null') |
|
| 668 | 660 | { |
| 669 | 661 | $conditionString .= $key . ' is null {op} '; |
| 670 | - } |
|
| 671 | - elseif (strtolower($operator) == 'not null') |
|
| 662 | + } elseif (strtolower($operator) == 'not null') |
|
| 672 | 663 | { |
| 673 | 664 | $conditionString .= $key . ' is not null {op} '; |
| 674 | - } |
|
| 675 | - elseif (strtolower($operator) == 'has') |
|
| 665 | + } elseif (strtolower($operator) == 'has') |
|
| 676 | 666 | { |
| 677 | 667 | $sql = $model->withTrashed()->has($key)->toSql(); |
| 678 | 668 | $conditions = $this->constructConditions($value, $model->$key()->getRelated()); |
| 679 | 669 | $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')') . ' and ' . $conditions['conditionString'] . ') {op} '; |
| 680 | 670 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 681 | - } |
|
| 682 | - else |
|
| 671 | + } else |
|
| 683 | 672 | { |
| 684 | 673 | $conditionString .= $key . ' ' . $operator . ' ? {op} '; |
| 685 | 674 | $conditionValues[] = $value; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * based on the docblock. |
| 125 | 125 | * |
| 126 | 126 | * @param array &$route |
| 127 | - * @param object $reflectionMethod |
|
| 127 | + * @param \ReflectionMethod $reflectionMethod |
|
| 128 | 128 | * @return void |
| 129 | 129 | */ |
| 130 | 130 | protected function processDocBlock(&$route, $reflectionMethod) |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * Generate post body for the given route. |
| 149 | 149 | * |
| 150 | 150 | * @param array &$route |
| 151 | - * @param object $reflectionMethod |
|
| 151 | + * @param \ReflectionMethod $reflectionMethod |
|
| 152 | 152 | * @param array $validationRules |
| 153 | 153 | * @return void |
| 154 | 154 | */ |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | if ($route) |
| 44 | 44 | { |
| 45 | 45 | $actoinArray = explode('@', $route['action']); |
| 46 | - if(array_get($actoinArray, 1, false)) |
|
| 46 | + if (array_get($actoinArray, 1, false)) |
|
| 47 | 47 | { |
| 48 | 48 | $controller = $actoinArray[0]; |
| 49 | 49 | $method = $actoinArray[1]; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $route['response'] = $this->getResponseObject($classProperties['model'], $route['name'], $route['returnDocBlock']); |
| 63 | 63 | |
| 64 | 64 | preg_match('/api\/([^#]+)\//iU', $route['uri'], $module); |
| 65 | - $docData['modules'][$module[1]][substr($route['prefix'], strlen('/api/' . $module[1] . '/') - 1)][] = $route; |
|
| 65 | + $docData['modules'][$module[1]][substr($route['prefix'], strlen('/api/'.$module[1].'/') - 1)][] = $route; |
|
| 66 | 66 | |
| 67 | 67 | $this->getModels($classProperties['model'], $docData); |
| 68 | 68 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | protected function getRoutes() |
| 83 | 83 | { |
| 84 | - return collect(\Route::getRoutes())->map(function ($route) { |
|
| 84 | + return collect(\Route::getRoutes())->map(function($route) { |
|
| 85 | 85 | if (strpos($route->uri(), 'api') !== false) |
| 86 | 86 | { |
| 87 | 87 | return [ |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | ]; |
| 114 | 114 | |
| 115 | 115 | |
| 116 | - if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) |
|
| 116 | + if ( ! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) |
|
| 117 | 117 | { |
| 118 | 118 | $route['headers']['Authorization'] = 'Bearer {token}'; |
| 119 | 119 | } |
@@ -167,16 +167,16 @@ discard block |
||
| 167 | 167 | } |
| 168 | 168 | else |
| 169 | 169 | { |
| 170 | - $route['body'] = eval('return ' . str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]) . ';'); |
|
| 170 | + $route['body'] = eval('return '.str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]).';'); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | foreach ($route['body'] as &$rule) |
| 174 | 174 | { |
| 175 | - if(strpos($rule, 'unique')) |
|
| 175 | + if (strpos($rule, 'unique')) |
|
| 176 | 176 | { |
| 177 | 177 | $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
| 178 | 178 | } |
| 179 | - elseif(strpos($rule, 'exists')) |
|
| 179 | + elseif (strpos($rule, 'exists')) |
|
| 180 | 180 | { |
| 181 | 181 | $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
| 182 | 182 | } |
@@ -249,10 +249,10 @@ discard block |
||
| 249 | 249 | $model = factory($modelClass)->make(); |
| 250 | 250 | $modelArr = $model->toArray(); |
| 251 | 251 | |
| 252 | - if ( $model->trans && ! $model->trans->count()) |
|
| 252 | + if ($model->trans && ! $model->trans->count()) |
|
| 253 | 253 | { |
| 254 | 254 | $modelArr['trans'] = [ |
| 255 | - 'en' => factory($modelClass . 'Translation')->make()->toArray() |
|
| 255 | + 'en' => factory($modelClass.'Translation')->make()->toArray() |
|
| 256 | 256 | ]; |
| 257 | 257 | } |
| 258 | 258 | |
@@ -164,8 +164,7 @@ discard block |
||
| 164 | 164 | if ($match[1] == '$this->validationRules') |
| 165 | 165 | { |
| 166 | 166 | $route['body'] = $validationRules; |
| 167 | - } |
|
| 168 | - else |
|
| 167 | + } else |
|
| 169 | 168 | { |
| 170 | 169 | $route['body'] = eval('return ' . str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]) . ';'); |
| 171 | 170 | } |
@@ -175,14 +174,12 @@ discard block |
||
| 175 | 174 | if(strpos($rule, 'unique')) |
| 176 | 175 | { |
| 177 | 176 | $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
| 178 | - } |
|
| 179 | - elseif(strpos($rule, 'exists')) |
|
| 177 | + } elseif(strpos($rule, 'exists')) |
|
| 180 | 178 | { |
| 181 | 179 | $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
| 182 | 180 | } |
| 183 | 181 | } |
| 184 | - } |
|
| 185 | - else |
|
| 182 | + } else |
|
| 186 | 183 | { |
| 187 | 184 | $route['body'] = 'conditions'; |
| 188 | 185 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * Get the notification's delivery channels. |
| 25 | 25 | * |
| 26 | 26 | * @param mixed $notifiable |
| 27 | - * @return array |
|
| 27 | + * @return string[] |
|
| 28 | 28 | */ |
| 29 | 29 | public function via($notifiable) |
| 30 | 30 | { |
@@ -43,6 +43,6 @@ |
||
| 43 | 43 | ->subject('Email verification') |
| 44 | 44 | ->line('Email verification') |
| 45 | 45 | ->line('To validate your email click on the button below') |
| 46 | - ->action('Verify your email', config('skeleton.confrim_email_url') . '/' . $notifiable->confirmation_code); |
|
| 46 | + ->action('Verify your email', config('skeleton.confrim_email_url').'/'.$notifiable->confirmation_code); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | \ No newline at end of file |
@@ -57,29 +57,23 @@ |
||
| 57 | 57 | if ($exception instanceof \Illuminate\Database\QueryException) |
| 58 | 58 | { |
| 59 | 59 | \ErrorHandler::dbQueryError(); |
| 60 | - } |
|
| 61 | - else if ($exception instanceof \predis\connection\connectionexception) |
|
| 60 | + } else if ($exception instanceof \predis\connection\connectionexception) |
|
| 62 | 61 | { |
| 63 | 62 | \ErrorHandler::redisNotRunning(); |
| 64 | - } |
|
| 65 | - else if ($exception instanceof \GuzzleHttp\Exception\ClientException) |
|
| 63 | + } else if ($exception instanceof \GuzzleHttp\Exception\ClientException) |
|
| 66 | 64 | { |
| 67 | 65 | \ErrorHandler::connectionError(); |
| 68 | - } |
|
| 69 | - else if ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpException) |
|
| 66 | + } else if ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpException) |
|
| 70 | 67 | { |
| 71 | 68 | return \Response::json($exception->getMessage(), $exception->getStatusCode()); |
| 72 | - } |
|
| 73 | - else if ($exception instanceof \Illuminate\Validation\ValidationException) |
|
| 69 | + } else if ($exception instanceof \Illuminate\Validation\ValidationException) |
|
| 74 | 70 | { |
| 75 | 71 | return \Response::json($exception->errors(), 422); |
| 76 | - } |
|
| 77 | - else if ( ! $exception instanceof \Symfony\Component\Debug\Exception\FatalErrorException) |
|
| 72 | + } else if ( ! $exception instanceof \Symfony\Component\Debug\Exception\FatalErrorException) |
|
| 78 | 73 | { |
| 79 | 74 | return parent::render($request, $exception); |
| 80 | 75 | } |
| 81 | - } |
|
| 82 | - else |
|
| 76 | + } else |
|
| 83 | 77 | { |
| 84 | 78 | return parent::render($request, $exception); |
| 85 | 79 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | { |
| 27 | 27 | $this->registerPolicies(); |
| 28 | 28 | |
| 29 | - Passport::routes(function ($router) { |
|
| 29 | + Passport::routes(function($router) { |
|
| 30 | 30 | $router->forAuthorization(); |
| 31 | 31 | $router->forAccessTokens(); |
| 32 | 32 | $router->forPersonalAccessTokens(); |
@@ -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('reporting', '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('reporting', 'Routes/api.php'); |
| 77 | 77 | }); |
| 78 | 78 | } |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | use Illuminate\Database\Eloquent\Model; |
| 4 | 4 | use Illuminate\Database\Eloquent\SoftDeletes; |
| 5 | 5 | |
| 6 | -class Report extends Model{ |
|
| 6 | +class Report extends Model { |
|
| 7 | 7 | |
| 8 | 8 | use SoftDeletes; |
| 9 | 9 | protected $table = 'reports'; |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | { |
| 41 | 41 | \ErrorHandler::notFound('report'); |
| 42 | 42 | } |
| 43 | - else if (! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) |
|
| 43 | + else if ( ! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) |
|
| 44 | 44 | { |
| 45 | 45 | \ErrorHandler::noPermissions(); |
| 46 | 46 | } |
@@ -39,8 +39,7 @@ discard block |
||
| 39 | 39 | if ( ! $report) |
| 40 | 40 | { |
| 41 | 41 | \ErrorHandler::notFound('report'); |
| 42 | - } |
|
| 43 | - else if (! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) |
|
| 42 | + } else if (! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) |
|
| 44 | 43 | { |
| 45 | 44 | \ErrorHandler::noPermissions(); |
| 46 | 45 | } |
@@ -61,8 +60,7 @@ discard block |
||
| 61 | 60 | if ($perPage) |
| 62 | 61 | { |
| 63 | 62 | return $report->paginate($perPage); |
| 64 | - } |
|
| 65 | - else |
|
| 63 | + } else |
|
| 66 | 64 | { |
| 67 | 65 | return $report->get(); |
| 68 | 66 | } |