@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | $statusCode=200; |
| 15 | 15 | } |
| 16 | 16 | $output=[ |
| 17 | - 'ret' => $statusCode, |
|
| 17 | + 'ret' => $statusCode, |
|
| 18 | 18 | 'desc' => is_null($desc) ? self::desc($statusCode) : $desc, |
| 19 | 19 | 'data' => $data |
| 20 | 20 | ]; |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | $statusCode=1000; |
| 28 | 28 | } |
| 29 | 29 | $output=[ |
| 30 | - 'ret' => $statusCode, |
|
| 30 | + 'ret' => $statusCode, |
|
| 31 | 31 | 'desc' => is_null($desc) ? self::desc($statusCode) : $desc, |
| 32 | 32 | 'data' => $data |
| 33 | 33 | ]; |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | '451' => "Unavailable For Legal Reasons", |
| 45 | 45 | |
| 46 | 46 | '1000' => "Unspecified Response", /** Under normal condictions those errors shouldn't been displayed to end users |
| 47 | - * unless they attempt to do so, some submissions should be intercepted |
|
| 48 | - * by the frontend before the request sended |
|
| 49 | - */ |
|
| 47 | + * unless they attempt to do so, some submissions should be intercepted |
|
| 48 | + * by the frontend before the request sended |
|
| 49 | + */ |
|
| 50 | 50 | '1001' => "Internal Sever Error", |
| 51 | 51 | '1002' => "Service Currently Unavailable", |
| 52 | 52 | '1003' => "Missing Params", |
@@ -10,21 +10,21 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class ApiController extends AdminController |
| 12 | 12 | { |
| 13 | - protected function paginate($items, $perPage = 15, $pageStart = 1) |
|
| 13 | + protected function paginate($items, $perPage=15, $pageStart=1) |
|
| 14 | 14 | { |
| 15 | - $offSet = ($pageStart * $perPage) - $perPage; |
|
| 16 | - $itemsForCurrentPage = array_slice($items, $offSet, $perPage, true); |
|
| 17 | - $paginator = new LengthAwarePaginator($itemsForCurrentPage, count($items), $perPage, Paginator::resolveCurrentPage(), ['path' => Paginator::resolveCurrentPath()]); |
|
| 15 | + $offSet=($pageStart * $perPage)-$perPage; |
|
| 16 | + $itemsForCurrentPage=array_slice($items, $offSet, $perPage, true); |
|
| 17 | + $paginator=new LengthAwarePaginator($itemsForCurrentPage, count($items), $perPage, Paginator::resolveCurrentPage(), ['path' => Paginator::resolveCurrentPath()]); |
|
| 18 | 18 | return $paginator; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function problems() |
| 22 | 22 | { |
| 23 | - $q = request()->q; |
|
| 23 | + $q=request()->q; |
|
| 24 | 24 | |
| 25 | - return $this->paginate(Problem::orderBy('pcode', 'asc')->get()->filter(function ($problem) use ($q) { |
|
| 26 | - return stripos($problem->readable_name, $q) !== false; |
|
| 27 | - })->values()->transform(function ($problem) { |
|
| 25 | + return $this->paginate(Problem::orderBy('pcode', 'asc')->get()->filter(function($problem) use ($q) { |
|
| 26 | + return stripos($problem->readable_name, $q)!==false; |
|
| 27 | + })->values()->transform(function($problem) { |
|
| 28 | 28 | return [ |
| 29 | 29 | 'id' => $problem->pid, |
| 30 | 30 | 'text' => $problem->readable_name, |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | public function users() |
| 36 | 36 | { |
| 37 | - $q = request()->q; |
|
| 37 | + $q=request()->q; |
|
| 38 | 38 | |
| 39 | - return $this->paginate(User::get()->filter(function ($user) use ($q) { |
|
| 40 | - return stripos($user->readable_name, $q) !== false; |
|
| 41 | - })->values()->transform(function ($user) { |
|
| 39 | + return $this->paginate(User::get()->filter(function($user) use ($q) { |
|
| 40 | + return stripos($user->readable_name, $q)!==false; |
|
| 41 | + })->values()->transform(function($user) { |
|
| 42 | 42 | return [ |
| 43 | 43 | 'id' => $user->id, |
| 44 | 44 | 'text' => $user->readable_name, |