@@ -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 | |
@@ -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 | } |
@@ -432,8 +432,7 @@ discard block |
||
| 432 | 432 | $model = $this->model->lockForUpdate()->find($value); |
| 433 | 433 | $model ? $model->update($data) : 0; |
| 434 | 434 | $saveLog ? \Logging::saveLog('update', class_basename($this->model), $this->getModel(), $value, $model) : false; |
| 435 | - } |
|
| 436 | - else |
|
| 435 | + } else |
|
| 437 | 436 | { |
| 438 | 437 | call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data, $saveLog){ |
| 439 | 438 | $model->update($data); |
@@ -464,8 +463,7 @@ discard block |
||
| 464 | 463 | $model->delete(); |
| 465 | 464 | $saveLog ? \Logging::saveLog('delete', class_basename($this->model), $this->getModel(), $value, $model) : false; |
| 466 | 465 | }); |
| 467 | - } |
|
| 468 | - else |
|
| 466 | + } else |
|
| 469 | 467 | { |
| 470 | 468 | \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) { |
| 471 | 469 | call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($saveLog){ |
@@ -582,14 +580,12 @@ discard block |
||
| 582 | 580 | $conditions = $this->constructConditions($value, $model); |
| 583 | 581 | $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']) . ' {op} '; |
| 584 | 582 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 585 | - } |
|
| 586 | - else if ($key == 'or') |
|
| 583 | + } else if ($key == 'or') |
|
| 587 | 584 | { |
| 588 | 585 | $conditions = $this->constructConditions($value, $model); |
| 589 | 586 | $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']) . ' {op} '; |
| 590 | 587 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 591 | - } |
|
| 592 | - else |
|
| 588 | + } else |
|
| 593 | 589 | { |
| 594 | 590 | if (is_array($value)) |
| 595 | 591 | { |
@@ -598,13 +594,11 @@ discard block |
||
| 598 | 594 | { |
| 599 | 595 | $value1 = $value['val1']; |
| 600 | 596 | $value2 = $value['val2']; |
| 601 | - } |
|
| 602 | - else |
|
| 597 | + } else |
|
| 603 | 598 | { |
| 604 | 599 | $value = array_key_exists('val', $value) ? $value['val'] : ''; |
| 605 | 600 | } |
| 606 | - } |
|
| 607 | - else |
|
| 601 | + } else |
|
| 608 | 602 | { |
| 609 | 603 | $operator = '='; |
| 610 | 604 | } |
@@ -616,29 +610,24 @@ discard block |
||
| 616 | 610 | |
| 617 | 611 | $conditionString .= $key . ' <= ? {op} '; |
| 618 | 612 | $conditionValues[] = $value2; |
| 619 | - } |
|
| 620 | - elseif (strtolower($operator) == 'in') |
|
| 613 | + } elseif (strtolower($operator) == 'in') |
|
| 621 | 614 | { |
| 622 | 615 | $conditionValues = array_merge($conditionValues, $value); |
| 623 | 616 | $inBindingsString = rtrim(str_repeat('?,', count($value)), ','); |
| 624 | 617 | $conditionString .= $key . ' in (' . rtrim($inBindingsString, ',') . ') {op} '; |
| 625 | - } |
|
| 626 | - elseif (strtolower($operator) == 'null') |
|
| 618 | + } elseif (strtolower($operator) == 'null') |
|
| 627 | 619 | { |
| 628 | 620 | $conditionString .= $key . ' is null {op} '; |
| 629 | - } |
|
| 630 | - elseif (strtolower($operator) == 'not null') |
|
| 621 | + } elseif (strtolower($operator) == 'not null') |
|
| 631 | 622 | { |
| 632 | 623 | $conditionString .= $key . ' is not null {op} '; |
| 633 | - } |
|
| 634 | - elseif (strtolower($operator) == 'has') |
|
| 624 | + } elseif (strtolower($operator) == 'has') |
|
| 635 | 625 | { |
| 636 | 626 | $sql = $model->withTrashed()->has($key)->toSql(); |
| 637 | 627 | $conditions = $this->constructConditions($value, $model->$key()->getRelated()); |
| 638 | 628 | $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')') . ' and ' . $conditions['conditionString'] . ') {op} '; |
| 639 | 629 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 640 | - } |
|
| 641 | - else |
|
| 630 | + } else |
|
| 642 | 631 | { |
| 643 | 632 | $conditionString .= $key . ' ' . $operator . ' ? {op} '; |
| 644 | 633 | $conditionValues[] = $value; |
@@ -156,8 +156,7 @@ discard block |
||
| 156 | 156 | if ($match[1] == '$this->validationRules') |
| 157 | 157 | { |
| 158 | 158 | $route['body'] = $validationRules; |
| 159 | - } |
|
| 160 | - else |
|
| 159 | + } else |
|
| 161 | 160 | { |
| 162 | 161 | $route['body'] = eval('return ' . $match[1] . ';'); |
| 163 | 162 | } |
@@ -167,14 +166,12 @@ discard block |
||
| 167 | 166 | if(strpos($rule, 'unique')) |
| 168 | 167 | { |
| 169 | 168 | $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
| 170 | - } |
|
| 171 | - elseif(strpos($rule, 'exists')) |
|
| 169 | + } elseif(strpos($rule, 'exists')) |
|
| 172 | 170 | { |
| 173 | 171 | $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
| 174 | 172 | } |
| 175 | 173 | } |
| 176 | - } |
|
| 177 | - else |
|
| 174 | + } else |
|
| 178 | 175 | { |
| 179 | 176 | $route['body'] = 'conditions'; |
| 180 | 177 | } |
@@ -68,8 +68,7 @@ discard block |
||
| 68 | 68 | return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
| 69 | 69 | return call_user_func_array([$this->repo, $name], $arguments); |
| 70 | 70 | }); |
| 71 | - } |
|
| 72 | - else if ($this->cacheConfig) |
|
| 71 | + } else if ($this->cacheConfig) |
|
| 73 | 72 | { |
| 74 | 73 | $this->cache->tags($this->cacheConfig)->flush(); |
| 75 | 74 | return call_user_func_array([$this->repo, $name], $arguments); |
@@ -93,8 +92,7 @@ discard block |
||
| 93 | 92 | if ($cacheConfig && in_array($name, $cacheConfig['cache'])) |
| 94 | 93 | { |
| 95 | 94 | $this->cacheConfig = 'cache'; |
| 96 | - } |
|
| 97 | - else if ($cacheConfig && isset($cacheConfig['clear'][$name])) |
|
| 95 | + } else if ($cacheConfig && isset($cacheConfig['clear'][$name])) |
|
| 98 | 96 | { |
| 99 | 97 | $this->cacheConfig = $cacheConfig['clear'][$name]; |
| 100 | 98 | } |