@@ -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 | } |
@@ -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 | } |
@@ -164,8 +164,7 @@ discard block |
||
| 164 | 164 | if ($match[1] == '$this->validationRules') |
| 165 | 165 | { |
| 166 | 166 | $route['body'] = $validationRules; |
| 167 | - } |
|
| 168 | - else |
|
| 167 | + } else |
|
| 169 | 168 | { |
| 170 | 169 | $route['body'] = eval('return ' . str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]) . ';'); |
| 171 | 170 | } |
@@ -175,14 +174,12 @@ discard block |
||
| 175 | 174 | if(strpos($rule, 'unique')) |
| 176 | 175 | { |
| 177 | 176 | $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
| 178 | - } |
|
| 179 | - elseif(strpos($rule, 'exists')) |
|
| 177 | + } elseif(strpos($rule, 'exists')) |
|
| 180 | 178 | { |
| 181 | 179 | $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
| 182 | 180 | } |
| 183 | 181 | } |
| 184 | - } |
|
| 185 | - else |
|
| 182 | + } else |
|
| 186 | 183 | { |
| 187 | 184 | $route['body'] = 'conditions'; |
| 188 | 185 | } |
@@ -84,8 +84,7 @@ discard block |
||
| 84 | 84 | return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
| 85 | 85 | return call_user_func_array([$this->repo, $name], $arguments); |
| 86 | 86 | }); |
| 87 | - } |
|
| 88 | - else if ($this->cacheConfig) |
|
| 87 | + } else if ($this->cacheConfig) |
|
| 89 | 88 | { |
| 90 | 89 | $this->cache->tags($this->cacheConfig)->flush(); |
| 91 | 90 | return call_user_func_array([$this->repo, $name], $arguments); |
@@ -109,8 +108,7 @@ discard block |
||
| 109 | 108 | if ($cacheConfig && in_array($name, $cacheConfig['cache'])) |
| 110 | 109 | { |
| 111 | 110 | $this->cacheConfig = 'cache'; |
| 112 | - } |
|
| 113 | - else if ($cacheConfig && isset($cacheConfig['clear'][$name])) |
|
| 111 | + } else if ($cacheConfig && isset($cacheConfig['clear'][$name])) |
|
| 114 | 112 | { |
| 115 | 113 | $this->cacheConfig = $cacheConfig['clear'][$name]; |
| 116 | 114 | } |
@@ -471,8 +471,7 @@ discard block |
||
| 471 | 471 | { |
| 472 | 472 | $model = $this->model->lockForUpdate()->find($value); |
| 473 | 473 | $model ? $model->update($data) : 0; |
| 474 | - } |
|
| 475 | - else |
|
| 474 | + } else |
|
| 476 | 475 | { |
| 477 | 476 | call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data){ |
| 478 | 477 | $model->update($data); |
@@ -501,8 +500,7 @@ discard block |
||
| 501 | 500 | |
| 502 | 501 | $model->delete(); |
| 503 | 502 | }); |
| 504 | - } |
|
| 505 | - else |
|
| 503 | + } else |
|
| 506 | 504 | { |
| 507 | 505 | \DB::transaction(function () use ($value, $attribute, &$result) { |
| 508 | 506 | call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model){ |
@@ -623,14 +621,12 @@ discard block |
||
| 623 | 621 | $conditions = $this->constructConditions($value, $model); |
| 624 | 622 | $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']) . ' {op} '; |
| 625 | 623 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 626 | - } |
|
| 627 | - else if ($key == 'or') |
|
| 624 | + } else if ($key == 'or') |
|
| 628 | 625 | { |
| 629 | 626 | $conditions = $this->constructConditions($value, $model); |
| 630 | 627 | $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']) . ' {op} '; |
| 631 | 628 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 632 | - } |
|
| 633 | - else |
|
| 629 | + } else |
|
| 634 | 630 | { |
| 635 | 631 | if (is_array($value)) |
| 636 | 632 | { |
@@ -639,13 +635,11 @@ discard block |
||
| 639 | 635 | { |
| 640 | 636 | $value1 = $value['val1']; |
| 641 | 637 | $value2 = $value['val2']; |
| 642 | - } |
|
| 643 | - else |
|
| 638 | + } else |
|
| 644 | 639 | { |
| 645 | 640 | $value = array_key_exists('val', $value) ? $value['val'] : ''; |
| 646 | 641 | } |
| 647 | - } |
|
| 648 | - else |
|
| 642 | + } else |
|
| 649 | 643 | { |
| 650 | 644 | $operator = '='; |
| 651 | 645 | } |
@@ -657,29 +651,24 @@ discard block |
||
| 657 | 651 | |
| 658 | 652 | $conditionString .= $key . ' <= ? {op} '; |
| 659 | 653 | $conditionValues[] = $value2; |
| 660 | - } |
|
| 661 | - elseif (strtolower($operator) == 'in') |
|
| 654 | + } elseif (strtolower($operator) == 'in') |
|
| 662 | 655 | { |
| 663 | 656 | $conditionValues = array_merge($conditionValues, $value); |
| 664 | 657 | $inBindingsString = rtrim(str_repeat('?,', count($value)), ','); |
| 665 | 658 | $conditionString .= $key . ' in (' . rtrim($inBindingsString, ',') . ') {op} '; |
| 666 | - } |
|
| 667 | - elseif (strtolower($operator) == 'null') |
|
| 659 | + } elseif (strtolower($operator) == 'null') |
|
| 668 | 660 | { |
| 669 | 661 | $conditionString .= $key . ' is null {op} '; |
| 670 | - } |
|
| 671 | - elseif (strtolower($operator) == 'not null') |
|
| 662 | + } elseif (strtolower($operator) == 'not null') |
|
| 672 | 663 | { |
| 673 | 664 | $conditionString .= $key . ' is not null {op} '; |
| 674 | - } |
|
| 675 | - elseif (strtolower($operator) == 'has') |
|
| 665 | + } elseif (strtolower($operator) == 'has') |
|
| 676 | 666 | { |
| 677 | 667 | $sql = $model->withTrashed()->has($key)->toSql(); |
| 678 | 668 | $conditions = $this->constructConditions($value, $model->$key()->getRelated()); |
| 679 | 669 | $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')') . ' and ' . $conditions['conditionString'] . ') {op} '; |
| 680 | 670 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 681 | - } |
|
| 682 | - else |
|
| 671 | + } else |
|
| 683 | 672 | { |
| 684 | 673 | $conditionString .= $key . ' ' . $operator . ' ? {op} '; |
| 685 | 674 | $conditionValues[] = $value; |
@@ -157,8 +157,7 @@ discard block |
||
| 157 | 157 | if ($request->has('id')) |
| 158 | 158 | { |
| 159 | 159 | $rule = str_replace('{id}', $request->get('id'), $rule); |
| 160 | - } |
|
| 161 | - else |
|
| 160 | + } else |
|
| 162 | 161 | { |
| 163 | 162 | $rule = str_replace(',{id}', '', $rule); |
| 164 | 163 | } |
@@ -228,10 +227,8 @@ discard block |
||
| 228 | 227 | } |
| 229 | 228 | |
| 230 | 229 | if ($isPasswordClient && (in_array($permission, $this->skipPermissionCheck) || \Core::users()->can($permission, $this->model))) |
| 231 | - {} |
|
| 232 | - elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
| 233 | - {} |
|
| 234 | - else |
|
| 230 | + {} elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
| 231 | + {} else |
|
| 235 | 232 | { |
| 236 | 233 | |
| 237 | 234 | \ErrorHandler::noPermissions(); |
@@ -97,8 +97,7 @@ |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $tokens[] = $device->device_token; |
| 100 | - } |
|
| 101 | - catch (\Exception $e) |
|
| 100 | + } catch (\Exception $e) |
|
| 102 | 101 | { |
| 103 | 102 | $device->forceDelete(); |
| 104 | 103 | } |
@@ -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 | } |
@@ -165,8 +161,7 @@ discard block |
||
| 165 | 161 | { |
| 166 | 162 | $user->confirmed = 1; |
| 167 | 163 | $user->save(); |
| 168 | - } |
|
| 169 | - else if ( ! config('skeleton.disable_confirm_email')) |
|
| 164 | + } else if ( ! config('skeleton.disable_confirm_email')) |
|
| 170 | 165 | { |
| 171 | 166 | $this->sendConfirmationEmail($user->email); |
| 172 | 167 | } |
@@ -189,12 +184,10 @@ discard block |
||
| 189 | 184 | if ( ! $this->hasGroup(['Admin'])) |
| 190 | 185 | { |
| 191 | 186 | \ErrorHandler::noPermissions(); |
| 192 | - } |
|
| 193 | - else if (\Auth::id() == $userId) |
|
| 187 | + } else if (\Auth::id() == $userId) |
|
| 194 | 188 | { |
| 195 | 189 | \ErrorHandler::noPermissions(); |
| 196 | - } |
|
| 197 | - else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
| 190 | + } else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
| 198 | 191 | { |
| 199 | 192 | \ErrorHandler::noPermissions(); |
| 200 | 193 | } |