| @@ -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 | |
| @@ -76,24 +76,19 @@ discard block | ||
| 76 | 76 | if ( ! $user = \Core::users()->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; | 
| 95 | - } | |
| 96 | - else | |
| 91 | + } else | |
| 97 | 92 |          { | 
| 98 | 93 | \ErrorHandler::loginFailed(); | 
| 99 | 94 | } | 
| @@ -135,12 +130,10 @@ discard block | ||
| 135 | 130 |          if ( ! $this->hasGroup('Admin')) | 
| 136 | 131 |          { | 
| 137 | 132 | \ErrorHandler::noPermissions(); | 
| 138 | - } | |
| 139 | - else if (\JWTAuth::parseToken()->authenticate()->id == $user_id) | |
| 133 | + } else if (\JWTAuth::parseToken()->authenticate()->id == $user_id) | |
| 140 | 134 |          { | 
| 141 | 135 | \ErrorHandler::noPermissions(); | 
| 142 | - } | |
| 143 | -        else if ($user->groups->lists('name')->search('Admin', true) !== false)  | |
| 136 | +        } else if ($user->groups->lists('name')->search('Admin', true) !== false)  | |
| 144 | 137 |          { | 
| 145 | 138 | \ErrorHandler::noPermissions(); | 
| 146 | 139 | } | 
| @@ -435,8 +435,7 @@ discard block | ||
| 435 | 435 | $model->delete(); | 
| 436 | 436 |                  $saveLog ? \Logging::saveLog('delete', class_basename($this->model), $this->getModel(), $value, $model) : false; | 
| 437 | 437 | }); | 
| 438 | - } | |
| 439 | - else | |
| 438 | + } else | |
| 440 | 439 |          { | 
| 441 | 440 |              \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) { | 
| 442 | 441 |                  call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model){ | 
| @@ -509,13 +508,11 @@ discard block | ||
| 509 | 508 |              { | 
| 510 | 509 |                  $conditionString  .= str_replace('{op}', 'and', $this->constructConditions($value)['conditionString']) . ' {op} '; | 
| 511 | 510 | $conditionValues = array_merge($conditionValues, $this->constructConditions($value)['conditionValues']); | 
| 512 | - } | |
| 513 | - else if ($key == 'or') | |
| 511 | + } else if ($key == 'or') | |
| 514 | 512 |              { | 
| 515 | 513 |                  $conditionString  .= str_replace('{op}', 'or', $this->constructConditions($value)['conditionString']) . ' {op} '; | 
| 516 | 514 | $conditionValues = array_merge($conditionValues, $this->constructConditions($value)['conditionValues']); | 
| 517 | - } | |
| 518 | - else | |
| 515 | + } else | |
| 519 | 516 |              { | 
| 520 | 517 |                  $conditionString  .= $key . '=? {op} '; | 
| 521 | 518 | $conditionValues[] = $value; | 
| @@ -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 | } |