@@ -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, |
@@ -48,16 +48,16 @@ |
||
48 | 48 | */ |
49 | 49 | protected function validator(array $data) |
50 | 50 | { |
51 | - $validator = [ |
|
51 | + $validator=[ |
|
52 | 52 | 'name' => ['required', 'string', 'max:16', 'unique:users'], |
53 | 53 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users', 'allowed_email_domain'], |
54 | 54 | 'password' => ['required', 'string', 'min:8', 'confirmed'], |
55 | 55 | 'agreement' => ['required'], |
56 | 56 | ]; |
57 | - $messages = []; |
|
58 | - if(config('function.password.strong')) { |
|
59 | - $validator['password'][] = 'regex:/^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,}$/'; |
|
60 | - $messages['password.regex'] = __('validation.password.strong'); |
|
57 | + $messages=[]; |
|
58 | + if (config('function.password.strong')) { |
|
59 | + $validator['password'][]='regex:/^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,}$/'; |
|
60 | + $messages['password.regex']=__('validation.password.strong'); |
|
61 | 61 | } |
62 | 62 | return Validator::make($data, $validator, $messages); |
63 | 63 | } |