@@ -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 | } |
@@ -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 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | /** |
| 57 | 57 | * Return the logged in user account. |
| 58 | 58 | * |
| 59 | - * @return \Illuminate\Http\Response |
|
| 59 | + * @return \Illuminate\Http\JsonResponse |
|
| 60 | 60 | */ |
| 61 | 61 | public function account() |
| 62 | 62 | { |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * Block the user. |
| 68 | 68 | * |
| 69 | 69 | * @param integer $id Id of the user. |
| 70 | - * @return \Illuminate\Http\Response |
|
| 70 | + * @return \Illuminate\Http\JsonResponse |
|
| 71 | 71 | */ |
| 72 | 72 | public function block($id) |
| 73 | 73 | { |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * Unblock the user. |
| 79 | 79 | * |
| 80 | 80 | * @param integer $id Id of the user. |
| 81 | - * @return \Illuminate\Http\Response |
|
| 81 | + * @return \Illuminate\Http\JsonResponse |
|
| 82 | 82 | */ |
| 83 | 83 | public function unblock($id) |
| 84 | 84 | { |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | /** |
| 89 | 89 | * Logout the user. |
| 90 | 90 | * |
| 91 | - * @return \Illuminate\Http\Response |
|
| 91 | + * @return \Illuminate\Http\JsonResponse |
|
| 92 | 92 | */ |
| 93 | 93 | public function logout() |
| 94 | 94 | { |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * Handle a registration request. |
| 100 | 100 | * |
| 101 | 101 | * @param \Illuminate\Http\Request $request |
| 102 | - * @return \Illuminate\Http\Response |
|
| 102 | + * @return \Illuminate\Http\JsonResponse |
|
| 103 | 103 | */ |
| 104 | 104 | public function register(Request $request) |
| 105 | 105 | { |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * Handle a login request to the application. |
| 117 | 117 | * |
| 118 | 118 | * @param \Illuminate\Http\Request $request |
| 119 | - * @return \Illuminate\Http\Response |
|
| 119 | + * @return \Illuminate\Http\JsonResponse |
|
| 120 | 120 | */ |
| 121 | 121 | public function login(Request $request) |
| 122 | 122 | { |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * Handle a social login request of the none admin to the application. |
| 134 | 134 | * |
| 135 | 135 | * @param \Illuminate\Http\Request $request |
| 136 | - * @return \Illuminate\Http\Response |
|
| 136 | + * @return \Illuminate\Http\JsonResponse |
|
| 137 | 137 | */ |
| 138 | 138 | public function loginSocial(Request $request) |
| 139 | 139 | { |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * Assign the given groups to the given user. |
| 151 | 151 | * |
| 152 | 152 | * @param \Illuminate\Http\Request $request |
| 153 | - * @return \Illuminate\Http\Response |
|
| 153 | + * @return \Illuminate\Http\JsonResponse |
|
| 154 | 154 | */ |
| 155 | 155 | public function assigngroups(Request $request) |
| 156 | 156 | { |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * Send a reset link to the given user. |
| 167 | 167 | * |
| 168 | 168 | * @param \Illuminate\Http\Request $request |
| 169 | - * @return \Illuminate\Http\Response |
|
| 169 | + * @return \Illuminate\Http\JsonResponse |
|
| 170 | 170 | */ |
| 171 | 171 | public function sendreset(Request $request) |
| 172 | 172 | { |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | * Reset the given user's password. |
| 180 | 180 | * |
| 181 | 181 | * @param \Illuminate\Http\Request $request |
| 182 | - * @return \Illuminate\Http\Response |
|
| 182 | + * @return \Illuminate\Http\JsonResponse |
|
| 183 | 183 | */ |
| 184 | 184 | public function resetpassword(Request $request) |
| 185 | 185 | { |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * Change the logged in user password. |
| 198 | 198 | * |
| 199 | 199 | * @param \Illuminate\Http\Request $request |
| 200 | - * @return \Illuminate\Http\Response |
|
| 200 | + * @return \Illuminate\Http\JsonResponse |
|
| 201 | 201 | */ |
| 202 | 202 | public function changePassword(Request $request) |
| 203 | 203 | { |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * Refresh the expired login token. |
| 215 | 215 | * |
| 216 | 216 | * @param string $refreshToken |
| 217 | - * @return \Illuminate\Http\Response |
|
| 217 | + * @return \Illuminate\Http\JsonResponse |
|
| 218 | 218 | */ |
| 219 | 219 | public function refreshtoken($refreshToken) |
| 220 | 220 | { |
@@ -228,8 +228,8 @@ discard block |
||
| 228 | 228 | * @param string $groupName The name of the requested group. |
| 229 | 229 | * @param integer $perPage Number of rows per page default 15. |
| 230 | 230 | * @param string $sortBy The name of the column to sort by. |
| 231 | - * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 232 | - * @return \Illuminate\Http\Response |
|
| 231 | + * @param integer $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 232 | + * @return \Illuminate\Http\JsonResponse |
|
| 233 | 233 | */ |
| 234 | 234 | public function group(Request $request, $groupName, $perPage = false, $sortBy = 'created_at', $desc = 1) |
| 235 | 235 | { |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * Save the given data to the logged in user. |
| 241 | 241 | * |
| 242 | 242 | * @param \Illuminate\Http\Request $request |
| 243 | - * @return \Illuminate\Http\Response |
|
| 243 | + * @return \Illuminate\Http\JsonResponse|null |
|
| 244 | 244 | */ |
| 245 | 245 | public function saveProfile(Request $request) |
| 246 | 246 | { |
@@ -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 | } |
@@ -123,6 +123,7 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @param array &$route |
| 125 | 125 | * @param object $reflectionMethod] |
| 126 | + * @param \ReflectionMethod $reflectionMethod |
|
| 126 | 127 | * @return void |
| 127 | 128 | */ |
| 128 | 129 | protected function processDocBlock(&$route, $reflectionMethod) |
@@ -145,7 +146,7 @@ discard block |
||
| 145 | 146 | * Generate post body for the given route. |
| 146 | 147 | * |
| 147 | 148 | * @param array &$route |
| 148 | - * @param object $reflectionMethod |
|
| 149 | + * @param \ReflectionMethod $reflectionMethod |
|
| 149 | 150 | * @param array $validationRules |
| 150 | 151 | * @return void |
| 151 | 152 | */ |
@@ -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 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @param array $relations |
| 34 | 34 | * @param string $sortBy |
| 35 | - * @param boolean $desc |
|
| 35 | + * @param integer $desc |
|
| 36 | 36 | * @param array $columns |
| 37 | 37 | * @return collection |
| 38 | 38 | */ |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @param integer $perPage |
| 51 | 51 | * @param array $relations |
| 52 | 52 | * @param string $sortBy |
| 53 | - * @param boolean $desc |
|
| 53 | + * @param integer $desc |
|
| 54 | 54 | * @param array $columns |
| 55 | 55 | * @return collection |
| 56 | 56 | */ |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * @param integer $perPage |
| 165 | 165 | * @param array $relations |
| 166 | 166 | * @param string $sortBy |
| 167 | - * @param boolean $desc |
|
| 167 | + * @param integer $desc |
|
| 168 | 168 | * @param array $columns |
| 169 | 169 | * @return collection |
| 170 | 170 | */ |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @param integer $perPage |
| 183 | 183 | * @param array $relations |
| 184 | 184 | * @param string $sortBy |
| 185 | - * @param boolean $desc |
|
| 185 | + * @param integer $desc |
|
| 186 | 186 | * @param array $columns |
| 187 | 187 | * @return collection |
| 188 | 188 | */ |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | /** |
| 198 | 198 | * Save the given model to the storage. |
| 199 | 199 | * |
| 200 | - * @param array $data |
|
| 200 | + * @param string $data |
|
| 201 | 201 | * @return void |
| 202 | 202 | */ |
| 203 | 203 | public function save(array $data) |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | * Update record in the storage based on the given |
| 443 | 443 | * condition. |
| 444 | 444 | * |
| 445 | - * @param var $value condition value |
|
| 445 | + * @param integer $value condition value |
|
| 446 | 446 | * @param array $data |
| 447 | 447 | * @param string $attribute condition column name |
| 448 | 448 | * @return void |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | * @param array $conditions array of conditions |
| 516 | 516 | * @param array $relations |
| 517 | 517 | * @param string $sortBy |
| 518 | - * @param boolean $desc |
|
| 518 | + * @param integer $desc |
|
| 519 | 519 | * @param array $columns |
| 520 | 520 | * @return collection |
| 521 | 521 | */ |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | * @param array $conditions array of conditions |
| 548 | 548 | * @param integer $perPage |
| 549 | 549 | * @param string $sortBy |
| 550 | - * @param boolean $desc |
|
| 550 | + * @param integer $desc |
|
| 551 | 551 | * @param array $columns |
| 552 | 552 | * @return collection |
| 553 | 553 | */ |
@@ -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; |
@@ -122,16 +122,13 @@ discard block |
||
| 122 | 122 | if ( ! $user = $this->first(['email' => $credentials['email']])) |
| 123 | 123 | { |
| 124 | 124 | \ErrorHandler::loginFailed(); |
| 125 | - } |
|
| 126 | - else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) |
|
| 125 | + } else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) |
|
| 127 | 126 | { |
| 128 | 127 | \ErrorHandler::loginFailed(); |
| 129 | - } |
|
| 130 | - else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) |
|
| 128 | + } else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) |
|
| 131 | 129 | { |
| 132 | 130 | \ErrorHandler::loginFailed(); |
| 133 | - } |
|
| 134 | - else if ($user->blocked) |
|
| 131 | + } else if ($user->blocked) |
|
| 135 | 132 | { |
| 136 | 133 | \ErrorHandler::userIsBlocked(); |
| 137 | 134 | } |
@@ -159,8 +156,7 @@ discard block |
||
| 159 | 156 | { |
| 160 | 157 | $data = ['email' => $user->email, 'password' => '']; |
| 161 | 158 | return $this->register($data); |
| 162 | - } |
|
| 163 | - else |
|
| 159 | + } else |
|
| 164 | 160 | { |
| 165 | 161 | if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => ''])) |
| 166 | 162 | { |
@@ -198,12 +194,10 @@ discard block |
||
| 198 | 194 | if ( ! $this->hasGroup('Admin')) |
| 199 | 195 | { |
| 200 | 196 | \ErrorHandler::noPermissions(); |
| 201 | - } |
|
| 202 | - else if (\Auth::id() == $user_id) |
|
| 197 | + } else if (\Auth::id() == $user_id) |
|
| 203 | 198 | { |
| 204 | 199 | \ErrorHandler::noPermissions(); |
| 205 | - } |
|
| 206 | - else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
| 200 | + } else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
| 207 | 201 | { |
| 208 | 202 | \ErrorHandler::noPermissions(); |
| 209 | 203 | } |
@@ -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 | } |