@@ -1,6 +1,5 @@ |
||
| 1 | 1 | <?php namespace App\Modules\Acl; |
| 2 | 2 | |
| 3 | -use Illuminate\Database\Eloquent\Model; |
|
| 4 | 3 | use App\User; |
| 5 | 4 | use Illuminate\Database\Eloquent\SoftDeletes; |
| 6 | 5 | |
@@ -170,8 +170,7 @@ |
||
| 170 | 170 | if ($request->has('id')) |
| 171 | 171 | { |
| 172 | 172 | $rule = str_replace('{id}', $request->get('id'), $rule); |
| 173 | - } |
|
| 174 | - else |
|
| 173 | + } else |
|
| 175 | 174 | { |
| 176 | 175 | $rule = str_replace(',{id}', '', $rule); |
| 177 | 176 | } |
@@ -76,24 +76,19 @@ discard block |
||
| 76 | 76 | if ( ! $user = $this->first(['email' => $credentials['email']])) |
| 77 | 77 | { |
| 78 | 78 | \ErrorHandler::loginFailed(); |
| 79 | - } |
|
| 80 | - else if ($adminLogin && $user->groups->lists('name')->search('Admin', true) === false) |
|
| 79 | + } else if ($adminLogin && $user->groups->lists('name')->search('Admin', true) === false) |
|
| 81 | 80 | { |
| 82 | 81 | \ErrorHandler::loginFailed(); |
| 83 | - } |
|
| 84 | - else if ( ! $adminLogin && $user->groups->lists('name')->search('Admin', true) !== false) |
|
| 82 | + } else if ( ! $adminLogin && $user->groups->lists('name')->search('Admin', true) !== false) |
|
| 85 | 83 | { |
| 86 | 84 | \ErrorHandler::loginFailed(); |
| 87 | - } |
|
| 88 | - else if ($user->blocked) |
|
| 85 | + } else if ($user->blocked) |
|
| 89 | 86 | { |
| 90 | 87 | \ErrorHandler::userIsBlocked(); |
| 91 | - } |
|
| 92 | - else if ($token = \JWTAuth::attempt($credentials)) |
|
| 88 | + } else if ($token = \JWTAuth::attempt($credentials)) |
|
| 93 | 89 | { |
| 94 | 90 | return ['token' => $token]; |
| 95 | - } |
|
| 96 | - else |
|
| 91 | + } else |
|
| 97 | 92 | { |
| 98 | 93 | \ErrorHandler::loginFailed(); |
| 99 | 94 | } |
@@ -111,8 +106,7 @@ discard block |
||
| 111 | 106 | { |
| 112 | 107 | $data = ['email' => $credentials['email'], 'password' => $credentials['access_token']]; |
| 113 | 108 | return $this->register($data); |
| 114 | - } |
|
| 115 | - else |
|
| 109 | + } else |
|
| 116 | 110 | { |
| 117 | 111 | if ($credentials['old_access_token']) |
| 118 | 112 | { |
@@ -126,8 +120,7 @@ discard block |
||
| 126 | 120 | $user->save(); |
| 127 | 121 | |
| 128 | 122 | return ['token' => \JWTAuth::fromUser($user)]; |
| 129 | - } |
|
| 130 | - else |
|
| 123 | + } else |
|
| 131 | 124 | { |
| 132 | 125 | $email = $credentials['email']; |
| 133 | 126 | $password = $credentials['access_token']; |
@@ -173,12 +166,10 @@ discard block |
||
| 173 | 166 | if ( ! $this->hasGroup('Admin')) |
| 174 | 167 | { |
| 175 | 168 | \ErrorHandler::noPermissions(); |
| 176 | - } |
|
| 177 | - else if (\JWTAuth::parseToken()->authenticate()->id == $user_id) |
|
| 169 | + } else if (\JWTAuth::parseToken()->authenticate()->id == $user_id) |
|
| 178 | 170 | { |
| 179 | 171 | \ErrorHandler::noPermissions(); |
| 180 | - } |
|
| 181 | - else if ($user->groups->lists('name')->search('Admin', true) !== false) |
|
| 172 | + } else if ($user->groups->lists('name')->search('Admin', true) !== false) |
|
| 182 | 173 | { |
| 183 | 174 | \ErrorHandler::noPermissions(); |
| 184 | 175 | } |
@@ -430,8 +430,7 @@ discard block |
||
| 430 | 430 | $model = $this->model->lockForUpdate()->find($value); |
| 431 | 431 | $model ? $model->update($data) : 0; |
| 432 | 432 | $saveLog ? $this->logs->saveLog('update', class_basename($this->model), $this->getModel(), $value, $model) : false; |
| 433 | - } |
|
| 434 | - else |
|
| 433 | + } else |
|
| 435 | 434 | { |
| 436 | 435 | call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data, $saveLog){ |
| 437 | 436 | $model->update($data); |
@@ -462,8 +461,7 @@ discard block |
||
| 462 | 461 | $model->delete(); |
| 463 | 462 | $saveLog ? \Logging::saveLog('delete', class_basename($this->model), $this->getModel(), $value, $model) : false; |
| 464 | 463 | }); |
| 465 | - } |
|
| 466 | - else |
|
| 464 | + } else |
|
| 467 | 465 | { |
| 468 | 466 | \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) { |
| 469 | 467 | call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model){ |
@@ -536,13 +534,11 @@ discard block |
||
| 536 | 534 | { |
| 537 | 535 | $conditionString .= str_replace('{op}', 'and', $this->constructConditions($value)['conditionString']) . ' {op} '; |
| 538 | 536 | $conditionValues = array_merge($conditionValues, $this->constructConditions($value)['conditionValues']); |
| 539 | - } |
|
| 540 | - else if ($key == 'or') |
|
| 537 | + } else if ($key == 'or') |
|
| 541 | 538 | { |
| 542 | 539 | $conditionString .= str_replace('{op}', 'or', $this->constructConditions($value)['conditionString']) . ' {op} '; |
| 543 | 540 | $conditionValues = array_merge($conditionValues, $this->constructConditions($value)['conditionValues']); |
| 544 | - } |
|
| 545 | - else |
|
| 541 | + } else |
|
| 546 | 542 | { |
| 547 | 543 | $conditionString .= $key . '=? {op} '; |
| 548 | 544 | $conditionValues[] = $value; |