@@ -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 | } |
@@ -67,8 +67,7 @@ |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | $tokens[] = $device->device_token; |
| 70 | - } |
|
| 71 | - catch (\Exception $e) |
|
| 70 | + } catch (\Exception $e) |
|
| 72 | 71 | { |
| 73 | 72 | $device->forceDelete(); |
| 74 | 73 | } |
@@ -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 | } |
@@ -453,8 +453,7 @@ discard block |
||
| 453 | 453 | { |
| 454 | 454 | $model = $this->model->lockForUpdate()->find($value); |
| 455 | 455 | $model ? $model->update($data) : 0; |
| 456 | - } |
|
| 457 | - else |
|
| 456 | + } else |
|
| 458 | 457 | { |
| 459 | 458 | call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data){ |
| 460 | 459 | $model->update($data); |
@@ -483,8 +482,7 @@ discard block |
||
| 483 | 482 | |
| 484 | 483 | $model->delete(); |
| 485 | 484 | }); |
| 486 | - } |
|
| 487 | - else |
|
| 485 | + } else |
|
| 488 | 486 | { |
| 489 | 487 | \DB::transaction(function () use ($value, $attribute, &$result) { |
| 490 | 488 | call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model){ |
@@ -605,14 +603,12 @@ discard block |
||
| 605 | 603 | $conditions = $this->constructConditions($value, $model); |
| 606 | 604 | $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']) . ' {op} '; |
| 607 | 605 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 608 | - } |
|
| 609 | - else if ($key == 'or') |
|
| 606 | + } else if ($key == 'or') |
|
| 610 | 607 | { |
| 611 | 608 | $conditions = $this->constructConditions($value, $model); |
| 612 | 609 | $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']) . ' {op} '; |
| 613 | 610 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 614 | - } |
|
| 615 | - else |
|
| 611 | + } else |
|
| 616 | 612 | { |
| 617 | 613 | if (is_array($value)) |
| 618 | 614 | { |
@@ -621,13 +617,11 @@ discard block |
||
| 621 | 617 | { |
| 622 | 618 | $value1 = $value['val1']; |
| 623 | 619 | $value2 = $value['val2']; |
| 624 | - } |
|
| 625 | - else |
|
| 620 | + } else |
|
| 626 | 621 | { |
| 627 | 622 | $value = array_key_exists('val', $value) ? $value['val'] : ''; |
| 628 | 623 | } |
| 629 | - } |
|
| 630 | - else |
|
| 624 | + } else |
|
| 631 | 625 | { |
| 632 | 626 | $operator = '='; |
| 633 | 627 | } |
@@ -639,29 +633,24 @@ discard block |
||
| 639 | 633 | |
| 640 | 634 | $conditionString .= $key . ' <= ? {op} '; |
| 641 | 635 | $conditionValues[] = $value2; |
| 642 | - } |
|
| 643 | - elseif (strtolower($operator) == 'in') |
|
| 636 | + } elseif (strtolower($operator) == 'in') |
|
| 644 | 637 | { |
| 645 | 638 | $conditionValues = array_merge($conditionValues, $value); |
| 646 | 639 | $inBindingsString = rtrim(str_repeat('?,', count($value)), ','); |
| 647 | 640 | $conditionString .= $key . ' in (' . rtrim($inBindingsString, ',') . ') {op} '; |
| 648 | - } |
|
| 649 | - elseif (strtolower($operator) == 'null') |
|
| 641 | + } elseif (strtolower($operator) == 'null') |
|
| 650 | 642 | { |
| 651 | 643 | $conditionString .= $key . ' is null {op} '; |
| 652 | - } |
|
| 653 | - elseif (strtolower($operator) == 'not null') |
|
| 644 | + } elseif (strtolower($operator) == 'not null') |
|
| 654 | 645 | { |
| 655 | 646 | $conditionString .= $key . ' is not null {op} '; |
| 656 | - } |
|
| 657 | - elseif (strtolower($operator) == 'has') |
|
| 647 | + } elseif (strtolower($operator) == 'has') |
|
| 658 | 648 | { |
| 659 | 649 | $sql = $model->withTrashed()->has($key)->toSql(); |
| 660 | 650 | $conditions = $this->constructConditions($value, $model->$key()->getRelated()); |
| 661 | 651 | $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')') . ' and ' . $conditions['conditionString'] . ') {op} '; |
| 662 | 652 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 663 | - } |
|
| 664 | - else |
|
| 653 | + } else |
|
| 665 | 654 | { |
| 666 | 655 | $conditionString .= $key . ' ' . $operator . ' ? {op} '; |
| 667 | 656 | $conditionValues[] = $value; |
@@ -173,8 +173,7 @@ discard block |
||
| 173 | 173 | if ($request->has('id')) |
| 174 | 174 | { |
| 175 | 175 | $rule = str_replace('{id}', $request->get('id'), $rule); |
| 176 | - } |
|
| 177 | - else |
|
| 176 | + } else |
|
| 178 | 177 | { |
| 179 | 178 | $rule = str_replace(',{id}', '', $rule); |
| 180 | 179 | } |
@@ -252,10 +251,8 @@ discard block |
||
| 252 | 251 | } |
| 253 | 252 | |
| 254 | 253 | if ($isPasswordClient && (in_array($permission, $this->skipPermissionCheck) || \Core::users()->can($permission, $this->model))) |
| 255 | - {} |
|
| 256 | - elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
| 257 | - {} |
|
| 258 | - else |
|
| 254 | + {} elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
| 255 | + {} else |
|
| 259 | 256 | { |
| 260 | 257 | |
| 261 | 258 | \ErrorHandler::noPermissions(); |
@@ -162,8 +162,7 @@ discard block |
||
| 162 | 162 | if ($match[1] == '$this->validationRules') |
| 163 | 163 | { |
| 164 | 164 | $route['body'] = $validationRules; |
| 165 | - } |
|
| 166 | - else |
|
| 165 | + } else |
|
| 167 | 166 | { |
| 168 | 167 | $route['body'] = eval('return ' . str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]) . ';'); |
| 169 | 168 | } |
@@ -173,14 +172,12 @@ discard block |
||
| 173 | 172 | if(strpos($rule, 'unique')) |
| 174 | 173 | { |
| 175 | 174 | $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
| 176 | - } |
|
| 177 | - elseif(strpos($rule, 'exists')) |
|
| 175 | + } elseif(strpos($rule, 'exists')) |
|
| 178 | 176 | { |
| 179 | 177 | $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
| 180 | 178 | } |
| 181 | 179 | } |
| 182 | - } |
|
| 183 | - else |
|
| 180 | + } else |
|
| 184 | 181 | { |
| 185 | 182 | $route['body'] = 'conditions'; |
| 186 | 183 | } |
@@ -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 | } |
@@ -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 | } |
@@ -143,8 +139,7 @@ discard block |
||
| 143 | 139 | { |
| 144 | 140 | $data = ['email' => $user->email, 'password' => '']; |
| 145 | 141 | return $this->register($data); |
| 146 | - } |
|
| 147 | - else |
|
| 142 | + } else |
|
| 148 | 143 | { |
| 149 | 144 | if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => ''])) |
| 150 | 145 | { |
@@ -187,12 +182,10 @@ discard block |
||
| 187 | 182 | if ( ! $this->hasGroup(['Admin'])) |
| 188 | 183 | { |
| 189 | 184 | \ErrorHandler::noPermissions(); |
| 190 | - } |
|
| 191 | - else if (\Auth::id() == $user_id) |
|
| 185 | + } else if (\Auth::id() == $user_id) |
|
| 192 | 186 | { |
| 193 | 187 | \ErrorHandler::noPermissions(); |
| 194 | - } |
|
| 195 | - else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
| 188 | + } else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
| 196 | 189 | { |
| 197 | 190 | \ErrorHandler::noPermissions(); |
| 198 | 191 | } |