@@ -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 | } |
@@ -38,8 +38,7 @@ discard block |
||
| 38 | 38 | if ( ! $report) |
| 39 | 39 | { |
| 40 | 40 | \ErrorHandler::notFound('report'); |
| 41 | - } |
|
| 42 | - else if ( ! \Core::users()->can($report->view_name, 'reports')) |
|
| 41 | + } else if ( ! \Core::users()->can($report->view_name, 'reports')) |
|
| 43 | 42 | { |
| 44 | 43 | \ErrorHandler::noPermissions(); |
| 45 | 44 | } |
@@ -60,8 +59,7 @@ discard block |
||
| 60 | 59 | if ($perPage) |
| 61 | 60 | { |
| 62 | 61 | return $report->paginate($perPage); |
| 63 | - } |
|
| 64 | - else |
|
| 62 | + } else |
|
| 65 | 63 | { |
| 66 | 64 | return $report->get(); |
| 67 | 65 | } |
@@ -103,24 +103,19 @@ discard block |
||
| 103 | 103 | if ( ! $user = $this->first(['email' => $credentials['email']])) |
| 104 | 104 | { |
| 105 | 105 | \ErrorHandler::loginFailed(); |
| 106 | - } |
|
| 107 | - else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) |
|
| 106 | + } else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) |
|
| 108 | 107 | { |
| 109 | 108 | \ErrorHandler::loginFailed(); |
| 110 | - } |
|
| 111 | - else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) |
|
| 109 | + } else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) |
|
| 112 | 110 | { |
| 113 | 111 | \ErrorHandler::loginFailed(); |
| 114 | - } |
|
| 115 | - else if ($user->blocked) |
|
| 112 | + } else if ($user->blocked) |
|
| 116 | 113 | { |
| 117 | 114 | \ErrorHandler::userIsBlocked(); |
| 118 | - } |
|
| 119 | - else if ($token = \JWTAuth::attempt($credentials)) |
|
| 115 | + } else if ($token = \JWTAuth::attempt($credentials)) |
|
| 120 | 116 | { |
| 121 | 117 | return ['token' => $token]; |
| 122 | - } |
|
| 123 | - else |
|
| 118 | + } else |
|
| 124 | 119 | { |
| 125 | 120 | \ErrorHandler::loginFailed(); |
| 126 | 121 | } |
@@ -146,8 +141,7 @@ discard block |
||
| 146 | 141 | { |
| 147 | 142 | $data = ['email' => $user->email, 'password' => '']; |
| 148 | 143 | return $this->register($data); |
| 149 | - } |
|
| 150 | - else |
|
| 144 | + } else |
|
| 151 | 145 | { |
| 152 | 146 | if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => ''])) |
| 153 | 147 | { |
@@ -193,12 +187,10 @@ discard block |
||
| 193 | 187 | if ( ! $this->hasGroup('Admin')) |
| 194 | 188 | { |
| 195 | 189 | \ErrorHandler::noPermissions(); |
| 196 | - } |
|
| 197 | - else if (\JWTAuth::parseToken()->authenticate()->id == $user_id) |
|
| 190 | + } else if (\JWTAuth::parseToken()->authenticate()->id == $user_id) |
|
| 198 | 191 | { |
| 199 | 192 | \ErrorHandler::noPermissions(); |
| 200 | - } |
|
| 201 | - else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
| 193 | + } else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
| 202 | 194 | { |
| 203 | 195 | \ErrorHandler::noPermissions(); |
| 204 | 196 | } |
@@ -1,6 +1,5 @@ |
||
| 1 | 1 | <?php namespace App\Modules\V1\Acl; |
| 2 | 2 | |
| 3 | -use Illuminate\Database\Eloquent\Model; |
|
| 4 | 3 | use App\User; |
| 5 | 4 | use Illuminate\Database\Eloquent\SoftDeletes; |
| 6 | 5 | |
@@ -1,7 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -use Illuminate\Http\Request; |
|
| 4 | - |
|
| 5 | 3 | /* |
| 6 | 4 | |-------------------------------------------------------------------------- |
| 7 | 5 | | API Routes |
@@ -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 | } |
@@ -430,8 +430,7 @@ discard block |
||
| 430 | 430 | $model = $this->model->lockForUpdate()->find($value); |
| 431 | 431 | $model ? $model->update($data) : 0; |
| 432 | 432 | $saveLog ? \Logging::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){ |
@@ -581,14 +579,12 @@ discard block |
||
| 581 | 579 | $conditions = $this->constructConditions($value, $model); |
| 582 | 580 | $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']) . ' {op} '; |
| 583 | 581 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 584 | - } |
|
| 585 | - else if ($key == 'or') |
|
| 582 | + } else if ($key == 'or') |
|
| 586 | 583 | { |
| 587 | 584 | $conditions = $this->constructConditions($value, $model); |
| 588 | 585 | $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']) . ' {op} '; |
| 589 | 586 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 590 | - } |
|
| 591 | - else |
|
| 587 | + } else |
|
| 592 | 588 | { |
| 593 | 589 | if (is_array($value)) |
| 594 | 590 | { |
@@ -597,13 +593,11 @@ discard block |
||
| 597 | 593 | { |
| 598 | 594 | $value1 = $value['val1']; |
| 599 | 595 | $value2 = $value['val2']; |
| 600 | - } |
|
| 601 | - else |
|
| 596 | + } else |
|
| 602 | 597 | { |
| 603 | 598 | $value = array_key_exists('val', $value) ? $value['val'] : ''; |
| 604 | 599 | } |
| 605 | - } |
|
| 606 | - else |
|
| 600 | + } else |
|
| 607 | 601 | { |
| 608 | 602 | $operator = '='; |
| 609 | 603 | } |
@@ -615,29 +609,24 @@ discard block |
||
| 615 | 609 | |
| 616 | 610 | $conditionString .= $key . ' <= ? {op} '; |
| 617 | 611 | $conditionValues[] = $value2; |
| 618 | - } |
|
| 619 | - elseif (strtolower($operator) == 'in') |
|
| 612 | + } elseif (strtolower($operator) == 'in') |
|
| 620 | 613 | { |
| 621 | 614 | $conditionValues = array_merge($conditionValues, $value); |
| 622 | 615 | $inBindingsString = rtrim(str_repeat('?,', count($value)), ','); |
| 623 | 616 | $conditionString .= $key . ' in (' . rtrim($inBindingsString, ',') . ') {op} '; |
| 624 | - } |
|
| 625 | - elseif (strtolower($operator) == 'null') |
|
| 617 | + } elseif (strtolower($operator) == 'null') |
|
| 626 | 618 | { |
| 627 | 619 | $conditionString .= $key . ' is null {op} '; |
| 628 | - } |
|
| 629 | - elseif (strtolower($operator) == 'not null') |
|
| 620 | + } elseif (strtolower($operator) == 'not null') |
|
| 630 | 621 | { |
| 631 | 622 | $conditionString .= $key . ' is not null {op} '; |
| 632 | - } |
|
| 633 | - elseif (strtolower($operator) == 'has') |
|
| 623 | + } elseif (strtolower($operator) == 'has') |
|
| 634 | 624 | { |
| 635 | 625 | $sql = $model->withTrashed()->has($key)->toSql(); |
| 636 | 626 | $conditions = $this->constructConditions($value, $model->first()->$key); |
| 637 | 627 | $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')') . ' and ' . $conditions['conditionString'] . ')'; |
| 638 | 628 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 639 | - } |
|
| 640 | - else |
|
| 629 | + } else |
|
| 641 | 630 | { |
| 642 | 631 | $conditionString .= $key . ' ' . $operator . ' ? {op} '; |
| 643 | 632 | $conditionValues[] = $value; |