Passed
Pull Request — master (#610)
by John
06:15
created
app/Exports/AccountExport.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
     public function __construct(array $data)
13 13
     {
14
-        $this->data = $data;
14
+        $this->data=$data;
15 15
     }
16 16
 
17 17
     public function array(): array
Please login to merge, or discard this patch.
app/Exports/GroupAnalysisExport.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
     }
29 29
 
30 30
     /**
31
-    * @return array
32
-    */
31
+     * @return array
32
+     */
33 33
     public function registerEvents(): array
34 34
     {
35 35
         return [
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
     }
47 47
 
48 48
     /**
49
-    * @return \Illuminate\Support\Collection
50
-    */
49
+     * @return \Illuminate\Support\Collection
50
+     */
51 51
     public function collection()
52 52
     {
53 53
         $maxium = $this->config['maxium'] ?? false;
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -16,16 +16,16 @@  discard block
 block discarded – undo
16 16
     private $member_data;
17 17
     private $config;
18 18
 
19
-    public function __construct($data, $config = [])
19
+    public function __construct($data, $config=[])
20 20
     {
21
-        if ($config['mode'] == 'contest') {
22
-            $this->contest_data = $data['contest_data'];
23
-            $this->member_data = $data['member_data'];
21
+        if ($config['mode']=='contest') {
22
+            $this->contest_data=$data['contest_data'];
23
+            $this->member_data=$data['member_data'];
24 24
         } else {
25
-            $this->member_data = $data['member_data'];
26
-            $this->tag_problems = $data['tag_problems'];
25
+            $this->member_data=$data['member_data'];
26
+            $this->tag_problems=$data['tag_problems'];
27 27
         }
28
-        $this->config = $config;
28
+        $this->config=$config;
29 29
     }
30 30
 
31 31
     /**
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
     public function registerEvents(): array
35 35
     {
36 36
         return [
37
-            AfterSheet::class => function (AfterSheet $event) {
38
-                if ($this->config['mode'] === 'contest') {
39
-                    $mergeCell = ['A1:A2','B1:E1'];
37
+            AfterSheet::class => function(AfterSheet $event) {
38
+                if ($this->config['mode']==='contest') {
39
+                    $mergeCell=['A1:A2', 'B1:E1'];
40 40
                     foreach ($this->contest_data as $c) {
41 41
                         array_push($mergeCell, $this->mergeCellColumnNext());
42 42
                     }
@@ -51,46 +51,46 @@  discard block
 block discarded – undo
51 51
     */
52 52
     public function collection()
53 53
     {
54
-        $maxium = $this->config['maxium'] ?? false;
55
-        $percent = $this->config['percent'] ?? false;
54
+        $maxium=$this->config['maxium'] ?? false;
55
+        $percent=$this->config['percent'] ?? false;
56 56
 
57
-        if ($this->config['mode'] == 'contest') {
58
-            $row_1 = ['Member','Total','','',''];
59
-            $row_2 = ['','Elo','Rank','Solved','Penalty'];
57
+        if ($this->config['mode']=='contest') {
58
+            $row_1=['Member', 'Total', '', '', ''];
59
+            $row_2=['', 'Elo', 'Rank', 'Solved', 'Penalty'];
60 60
             foreach ($this->contest_data as $contest) {
61
-                array_push($row_1, $contest['name'], '','');
62
-                array_push($row_2, 'Rank','Solved', 'Penalty');
61
+                array_push($row_1, $contest['name'], '', '');
62
+                array_push($row_2, 'Rank', 'Solved', 'Penalty');
63 63
             }
64
-            $data = [$row_1,$row_2];
64
+            $data=[$row_1, $row_2];
65 65
             foreach ($this->member_data as $member) {
66
-                $display_name = $member['name'];
66
+                $display_name=$member['name'];
67 67
                 if (!empty($member['nick_name'])) {
68
-                    $display_name .= ' ('.$member['nick_name'].')';
68
+                    $display_name.=' ('.$member['nick_name'].')';
69 69
                 }
70
-                $row = [
70
+                $row=[
71 71
                     $display_name,
72 72
                     $member['elo'],
73 73
                     !empty($member['rank_ave']) ? round($member['rank_ave'], 1) : '-',
74
-                    $percent === 'true'  ? ($member['problem_all'] != 0 ? round($member['solved_all'] / $member['problem_all'] * 100, 1) : '-'). ' %'
75
-                            : ($maxium === 'true'  ? $member['solved_all'] . ' / ' . $member['problem_all'] : $member['solved_all']),
74
+                    $percent==='true' ? ($member['problem_all']!=0 ? round($member['solved_all'] / $member['problem_all'] * 100, 1) : '-').' %'
75
+                            : ($maxium==='true' ? $member['solved_all'].' / '.$member['problem_all'] : $member['solved_all']),
76 76
                     round($member['penalty']),
77 77
                 ];
78 78
                 foreach ($this->contest_data as $contest) {
79 79
                     if (in_array($contest['cid'], array_keys($member['contest_detial']))) {
80
-                        $contest_detial = $member['contest_detial'][$contest['cid']];
80
+                        $contest_detial=$member['contest_detial'][$contest['cid']];
81 81
                         array_push(
82 82
                             $row,
83 83
                             $contest_detial['rank'],
84
-                            $percent === 'true' ? (round($contest_detial['solved'] / $contest_detial['problems'] * 100, 1) . ' %')
85
-                                    : ($maxium === 'true' ? $contest_detial['solved'].' / '.$contest_detial['problems'] : $contest_detial['solved']),
84
+                            $percent==='true' ? (round($contest_detial['solved'] / $contest_detial['problems'] * 100, 1).' %')
85
+                                    : ($maxium==='true' ? $contest_detial['solved'].' / '.$contest_detial['problems'] : $contest_detial['solved']),
86 86
                             round($contest_detial['penalty'])
87 87
                         );
88 88
                     } else {
89 89
                         array_push(
90 90
                             $row,
91 91
                             '-',
92
-                            $percent === 'true' ? '- %'
93
-                                    : ($maxium === 'true' ? '- / -' : ' - '),
92
+                            $percent==='true' ? '- %'
93
+                                    : ($maxium==='true' ? '- / -' : ' - '),
94 94
                             0
95 95
                         );
96 96
                     }
@@ -98,27 +98,27 @@  discard block
 block discarded – undo
98 98
                 array_push($data, $row);
99 99
             }
100 100
         } else {
101
-            $row_1 = ['Member'];
102
-            $row_2 = [''];
101
+            $row_1=['Member'];
102
+            $row_2=[''];
103 103
             foreach ($this->tag_problems as $tag => $tag_problem_set) {
104 104
                 array_push($row_1, $tag);
105 105
                 array_push($row_2, 'Solved');
106 106
             }
107
-            $data = [$row_1,$row_2];
107
+            $data=[$row_1, $row_2];
108 108
             foreach ($this->member_data as $member) {
109
-                $display_name = $member['name'];
109
+                $display_name=$member['name'];
110 110
                 if (!empty($member['nick_name'])) {
111
-                    $display_name .= ' ('.$member['nick_name'].')';
111
+                    $display_name.=' ('.$member['nick_name'].')';
112 112
                 }
113
-                $row = [
113
+                $row=[
114 114
                     $display_name,
115 115
                 ];
116 116
                 foreach ($member['completion'] as $tag => $tag_completion) {
117
-                    $count = count($tag_completion);
118
-                    $solved = eval('return '.join('+', array_values($tag_completion)).';');
117
+                    $count=count($tag_completion);
118
+                    $solved=eval('return '.join('+', array_values($tag_completion)).';');
119 119
                     array_push(
120 120
                         $row,
121
-                        $percent === 'true' ? (round($solved / $count * 100, 1) . ' %') : ($maxium  === 'true' ? $solved .' / '.$count : $solved)
121
+                        $percent==='true' ? (round($solved / $count * 100, 1).' %') : ($maxium==='true' ? $solved.' / '.$count : $solved)
122 122
                     );
123 123
                 }
124 124
                 array_push($data, $row);
@@ -129,33 +129,33 @@  discard block
 block discarded – undo
129 129
 
130 130
     private function mergeCellColumnNext()
131 131
     {
132
-        static $columns = [
133
-            [2],[4]
132
+        static $columns=[
133
+            [2], [4]
134 134
         ];
135
-        $columns_str = ['',''];
136
-        $chars = str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
135
+        $columns_str=['', ''];
136
+        $chars=str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
137 137
         foreach ($columns as $key => &$column) {
138
-            $column[0] += 3;
139
-            if ($column[0] > 25) {
138
+            $column[0]+=3;
139
+            if ($column[0]>25) {
140 140
                 if (isset($column[1])) {
141
-                    $column[1] += 1;
142
-                    if ($column[1] > 25) {
141
+                    $column[1]+=1;
142
+                    if ($column[1]>25) {
143 143
                         if (isset($column[2])) {
144
-                            $column[2] += 1;
144
+                            $column[2]+=1;
145 145
                         } else {
146
-                            $column[2] = 0;
146
+                            $column[2]=0;
147 147
                         }
148 148
                     }
149 149
                 } else {
150
-                    $column[1] = 0;
150
+                    $column[1]=0;
151 151
                 }
152 152
             }
153
-            $columns_str[$key] = '';
154
-            $reverse_column = array_reverse($column);
153
+            $columns_str[$key]='';
154
+            $reverse_column=array_reverse($column);
155 155
             foreach ($reverse_column as $ord) {
156
-                $columns_str[$key] .= $chars[$ord];
156
+                $columns_str[$key].=$chars[$ord];
157 157
             }
158
-            $columns_str[$key] .= '1';
158
+            $columns_str[$key].='1';
159 159
         }
160 160
         return $columns_str[0].':'.$columns_str[1];
161 161
     }
Please login to merge, or discard this patch.
app/Http/Controllers/Auth/ForgotPasswordController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
      */
38 38
     public function showLinkRequestForm()
39 39
     {
40
-        return view('auth.passwords.email',[
40
+        return view('auth.passwords.email', [
41 41
             'page_title'=>"Reset Password",
42 42
             'site_title'=>config("app.name"),
43 43
             'navigation' => "Account"
Please login to merge, or discard this patch.
app/Http/Middleware/Privileged.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,16 +18,16 @@
 block discarded – undo
18 18
     public function handle($request, Closure $next)
19 19
     {
20 20
         if (Auth::check()) {
21
-            if(isset($request->gcode)){
21
+            if (isset($request->gcode)) {
22 22
                 //group privilege
23 23
                 $groupModel=new GroupModel();
24
-                if($groupModel->judgeClearance($groupModel->gid($request->gcode), Auth::user()->id)>=2){
24
+                if ($groupModel->judgeClearance($groupModel->gid($request->gcode), Auth::user()->id)>=2) {
25 25
                     return $next($request);
26 26
                 }
27
-            }elseif(isset($request->cid)) {
27
+            }elseif (isset($request->cid)) {
28 28
                 //contest privilege
29 29
                 $contestModel=new ContestModel();
30
-                if($contestModel->judgeClearance($request->cid, Auth::user()->id)==3){
30
+                if ($contestModel->judgeClearance($request->cid, Auth::user()->id)==3) {
31 31
                     return $next($request);
32 32
                 }
33 33
             }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
                 if($groupModel->judgeClearance($groupModel->gid($request->gcode), Auth::user()->id)>=2){
25 25
                     return $next($request);
26 26
                 }
27
-            }elseif(isset($request->cid)) {
27
+            } elseif(isset($request->cid)) {
28 28
                 //contest privilege
29 29
                 $contestModel=new ContestModel();
30 30
                 if($contestModel->judgeClearance($request->cid, Auth::user()->id)==3){
Please login to merge, or discard this patch.
app/Models/RankModel.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use Illuminate\Support\Facades\DB;
8 8
 use Illuminate\Support\Arr;
9 9
 use App\Models\Rating\RatingCalculator;
10
-use Cache,Redis;
10
+use Cache, Redis;
11 11
 
12 12
 class RankModel extends Model
13 13
 {
@@ -65,28 +65,28 @@  discard block
 block discarded – undo
65 65
 
66 66
     public static function getColor($rankTitle)
67 67
     {
68
-        if(is_null($rankTitle)) return "";
68
+        if (is_null($rankTitle)) return "";
69 69
         return self::$casualRanking[$rankTitle];
70 70
     }
71 71
 
72 72
     public static function getProfessionalColor($rankTitle)
73 73
     {
74
-        if(is_null($rankTitle)) return self::$professionalRanking["None"];
74
+        if (is_null($rankTitle)) return self::$professionalRanking["None"];
75 75
         return self::$professionalRanking[$rankTitle];
76 76
     }
77 77
 
78 78
     public function list($num)
79 79
     {
80 80
         $rankList=Cache::tags(['rank'])->get('general');
81
-        if($rankList==null) $rankList=[];
82
-        $rankList=array_slice($rankList,0,$num);
83
-        $userInfoRaw=DB::table("users")->select("id as uid","avatar","name")->get()->all();
81
+        if ($rankList==null) $rankList=[];
82
+        $rankList=array_slice($rankList, 0, $num);
83
+        $userInfoRaw=DB::table("users")->select("id as uid", "avatar", "name")->get()->all();
84 84
         $userInfo=[];
85
-        foreach($userInfoRaw as $u){
85
+        foreach ($userInfoRaw as $u) {
86 86
             $userInfo[$u["uid"]]=$u;
87 87
         }
88
-        foreach($rankList as &$r){
89
-            $r["details"]=isset($userInfo[$r["uid"]])?$userInfo[$r["uid"]]:[];
88
+        foreach ($rankList as &$r) {
89
+            $r["details"]=isset($userInfo[$r["uid"]]) ? $userInfo[$r["uid"]] : [];
90 90
         }
91 91
         // var_dump($rankList); exit();
92 92
         return $rankList;
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
                     $rankSolved=$rankItem["totValue"];
110 110
                 }
111 111
                 $rankTitle=$this->getRankTitle($rankValue);
112
-                Cache::tags(['rank',$rankItem["uid"]])->put("rank", $rankValue, 86400);
113
-                Cache::tags(['rank',$rankItem["uid"]])->put("title", $rankTitle, 86400);
112
+                Cache::tags(['rank', $rankItem["uid"]])->put("rank", $rankValue, 86400);
113
+                Cache::tags(['rank', $rankItem["uid"]])->put("title", $rankTitle, 86400);
114 114
                 $rankListCached[]=[
115 115
                     "uid"=>$rankItem["uid"],
116 116
                     "rank"=>$rankValue,
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
 
128 128
     public function getProfessionalRanking()
129 129
     {
130
-        $professionalRankList = [];
131
-        $verifiedUsers = DB::table("users")->select("professional_rate","id as uid","avatar","name")->get()->all();
132
-        $rankIter = 0;
133
-        foreach($verifiedUsers as $user) {
134
-            $rankVal = $user['professional_rate'];
135
-            $rankTitle = self::getProfessionalTitle($rankVal);
136
-            $titleColor = self::getProfessionalColor($rankTitle);
137
-            $professionalRankList[$rankIter++] = [
130
+        $professionalRankList=[];
131
+        $verifiedUsers=DB::table("users")->select("professional_rate", "id as uid", "avatar", "name")->get()->all();
132
+        $rankIter=0;
133
+        foreach ($verifiedUsers as $user) {
134
+            $rankVal=$user['professional_rate'];
135
+            $rankTitle=self::getProfessionalTitle($rankVal);
136
+            $titleColor=self::getProfessionalColor($rankTitle);
137
+            $professionalRankList[$rankIter++]=[
138 138
                 "name"=>$user["name"],
139 139
                 "uid"=>$user["uid"],
140 140
                 "avatar"=>$user["avatar"],
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
                 $tot+=$c;
157 157
             }
158 158
             foreach ($this->casualRankingPer as &$c) {
159
-                $c=round($c*$totUsers/$tot);
159
+                $c=round($c * $totUsers / $tot);
160 160
                 $cur+=$c;
161 161
                 $c=$cur;
162 162
             }
@@ -167,16 +167,16 @@  discard block
 block discarded – undo
167 167
 
168 168
     public function getRankTitle($rankVal)
169 169
     {
170
-        foreach($this->casualRankingPer as $title=>$c){
171
-            if($rankVal<=$c) return $title;
170
+        foreach ($this->casualRankingPer as $title=>$c) {
171
+            if ($rankVal<=$c) return $title;
172 172
         }
173 173
         return Arr::last($this->casualRankingPer);
174 174
     }
175 175
 
176 176
     public static function getProfessionalTitle($rankVal)
177 177
     {
178
-        foreach(self::$professionalRankingPer as $title=>$point) {
179
-            if($rankVal >= $point) return $title;
178
+        foreach (self::$professionalRankingPer as $title=>$point) {
179
+            if ($rankVal>=$point) return $title;
180 180
         }
181 181
         return Arr::last(self::$professionalRankingPer);
182 182
     }
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,20 +65,26 @@  discard block
 block discarded – undo
65 65
 
66 66
     public static function getColor($rankTitle)
67 67
     {
68
-        if(is_null($rankTitle)) return "";
68
+        if(is_null($rankTitle)) {
69
+            return "";
70
+        }
69 71
         return self::$casualRanking[$rankTitle];
70 72
     }
71 73
 
72 74
     public static function getProfessionalColor($rankTitle)
73 75
     {
74
-        if(is_null($rankTitle)) return self::$professionalRanking["None"];
76
+        if(is_null($rankTitle)) {
77
+            return self::$professionalRanking["None"];
78
+        }
75 79
         return self::$professionalRanking[$rankTitle];
76 80
     }
77 81
 
78 82
     public function list($num)
79 83
     {
80 84
         $rankList=Cache::tags(['rank'])->get('general');
81
-        if($rankList==null) $rankList=[];
85
+        if($rankList==null) {
86
+            $rankList=[];
87
+        }
82 88
         $rankList=array_slice($rankList,0,$num);
83 89
         $userInfoRaw=DB::table("users")->select("id as uid","avatar","name")->get()->all();
84 90
         $userInfo=[];
@@ -168,7 +174,9 @@  discard block
 block discarded – undo
168 174
     public function getRankTitle($rankVal)
169 175
     {
170 176
         foreach($this->casualRankingPer as $title=>$c){
171
-            if($rankVal<=$c) return $title;
177
+            if($rankVal<=$c) {
178
+                return $title;
179
+            }
172 180
         }
173 181
         return Arr::last($this->casualRankingPer);
174 182
     }
@@ -176,7 +184,9 @@  discard block
 block discarded – undo
176 184
     public static function getProfessionalTitle($rankVal)
177 185
     {
178 186
         foreach(self::$professionalRankingPer as $title=>$point) {
179
-            if($rankVal >= $point) return $title;
187
+            if($rankVal >= $point) {
188
+                return $title;
189
+            }
180 190
         }
181 191
         return Arr::last(self::$professionalRankingPer);
182 192
     }
Please login to merge, or discard this patch.
app/Console/Commands/Babel/SyncContest.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
      *
15 15
      * @var string
16 16
      */
17
-    protected $signature = 'babel:sync {extension : The package name of the extension} {--vcid= : The target contest of the Crawler} {--gid=1 : The holding group}';
17
+    protected $signature='babel:sync {extension : The package name of the extension} {--vcid= : The target contest of the Crawler} {--gid=1 : The holding group}';
18 18
 
19 19
     /**
20 20
      * The console command description.
21 21
      *
22 22
      * @var string
23 23
      */
24
-    protected $description = 'Crawl contests for a given Babel Extension to NOJ';
24
+    protected $description='Crawl contests for a given Babel Extension to NOJ';
25 25
 
26 26
     /**
27 27
      * Create a new command instance.
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function handle()
42 42
     {
43
-        $extension = $this->argument('extension');
44
-        $vcid = $this->option('vcid');
45
-        $gid = $this->option('gid');
46
-        $className = "App\\Babel\\Extension\\$extension\\Synchronizer";
47
-        $all_data = [
43
+        $extension=$this->argument('extension');
44
+        $vcid=$this->option('vcid');
45
+        $gid=$this->option('gid');
46
+        $className="App\\Babel\\Extension\\$extension\\Synchronizer";
47
+        $all_data=[
48 48
             'oj'=>$extension,
49 49
             'vcid'=>$vcid,
50 50
             'gid'=>$gid,
51 51
         ];
52
-        $Sync = new $className($all_data);
52
+        $Sync=new $className($all_data);
53 53
         $Sync->crawlContest();
54 54
     }
55 55
 }
Please login to merge, or discard this patch.
app/Console/Commands/Babel/RefreshRank.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
      *
15 15
      * @var string
16 16
      */
17
-    protected $signature = 'babel:rerank {extension : The package name of the extension} {--vcid= : The target contest of the Crawler} {--gid=1 : The holding group} {--cid= : The NOJ contest}';
17
+    protected $signature='babel:rerank {extension : The package name of the extension} {--vcid= : The target contest of the Crawler} {--gid=1 : The holding group} {--cid= : The NOJ contest}';
18 18
 
19 19
     /**
20 20
      * The console command description.
21 21
      *
22 22
      * @var string
23 23
      */
24
-    protected $description = 'Refresh Rank from a remote contest';
24
+    protected $description='Refresh Rank from a remote contest';
25 25
 
26 26
     /**
27 27
      * Create a new command instance.
@@ -40,18 +40,18 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function handle()
42 42
     {
43
-        $extension = $this->argument('extension');
44
-        $vcid = $this->option('vcid');
45
-        $gid = $this->option('gid');
46
-        $cid = $this->option('cid');
47
-        $className = "App\\Babel\\Extension\\$extension\\Synchronizer";
48
-        $all_data = [
43
+        $extension=$this->argument('extension');
44
+        $vcid=$this->option('vcid');
45
+        $gid=$this->option('gid');
46
+        $cid=$this->option('cid');
47
+        $className="App\\Babel\\Extension\\$extension\\Synchronizer";
48
+        $all_data=[
49 49
             'oj'=>$extension,
50 50
             'vcid'=>$vcid,
51 51
             'gid'=>$gid,
52 52
             'cid'=>$cid,
53 53
         ];
54
-        $Sync = new $className($all_data);
54
+        $Sync=new $className($all_data);
55 55
         $Sync->crawlRank();
56 56
     }
57 57
 }
Please login to merge, or discard this patch.
app/Http/Controllers/Ajax/SearchController.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,34 +23,34 @@
 block discarded – undo
23 23
         if (!$request->has('search_key')) {
24 24
             return ResponseModel::err(1003);
25 25
         }
26
-        $key  = $request->input('search_key');
27
-        $all_result  = [];
28
-        $search_from = [
26
+        $key=$request->input('search_key');
27
+        $all_result=[];
28
+        $search_from=[
29 29
             'users'         => \App\Models\Search\UserSearchModel::class,
30 30
             'problems'      => \App\Models\Search\ProblemSearchModel::class,
31 31
             'contests'      => \App\Models\Search\ContestSearchModel::class,
32 32
             'groups'        => \App\Models\Search\GroupSearchModel::class,
33 33
         ];
34 34
         foreach ($search_from as $name => $model_class) {
35
-            if(class_exists($model_class)){
36
-                $model = new $model_class();
37
-                if(!method_exists($model,'search')){
38
-                    $all_result[$name] = [
35
+            if (class_exists($model_class)) {
36
+                $model=new $model_class();
37
+                if (!method_exists($model, 'search')) {
38
+                    $all_result[$name]=[
39 39
                         'code' => -1,
40 40
                         'msg' => 'cannot find search method in '.$model_class
41 41
                     ];
42 42
                     continue;
43 43
                 }
44
-                $result = $model->search($key);
45
-                $all_result[$name] = $result;
46
-            }else{
47
-                $all_result[$name] = [
44
+                $result=$model->search($key);
45
+                $all_result[$name]=$result;
46
+            } else {
47
+                $all_result[$name]=[
48 48
                     'code' => -1,
49 49
                     'msg' => 'cannot find class named '.$model_class
50
-                ];;
50
+                ]; ;
51 51
                 continue;
52 52
             }
53 53
         }
54
-        return ResponseModel::success(200,'Successful',$all_result);
54
+        return ResponseModel::success(200, 'Successful', $all_result);
55 55
     }
56 56
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
                 }
44 44
                 $result = $model->search($key);
45 45
                 $all_result[$name] = $result;
46
-            }else{
46
+            } else{
47 47
                 $all_result[$name] = [
48 48
                     'code' => -1,
49 49
                     'msg' => 'cannot find class named '.$model_class
Please login to merge, or discard this patch.
app/Models/Search/GroupSearchModel.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,19 +12,19 @@
 block discarded – undo
12 12
 
13 13
     public function search($key)
14 14
     {
15
-        $result = [];
15
+        $result=[];
16 16
         //group name or gcode find
17
-        if(strlen($key) >= 2){
18
-            $ret = self::where(function($query) use ($key){
19
-                $query->whereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)',[$key])
17
+        if (strlen($key)>=2) {
18
+            $ret=self::where(function($query) use ($key){
19
+                $query->whereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)', [$key])
20 20
                     ->orWhere('gcode', $key);
21 21
                 })
22
-                ->where('public',1)
23
-                ->select('gid','gcode', 'img', 'name', 'description')
22
+                ->where('public', 1)
23
+                ->select('gid', 'gcode', 'img', 'name', 'description')
24 24
                 ->limit(120)
25 25
                 ->get()->all();
26
-            if(!empty($ret)){
27
-                $result += $ret;
26
+            if (!empty($ret)) {
27
+                $result+=$ret;
28 28
             }
29 29
         }
30 30
 
Please login to merge, or discard this patch.