Passed
Push — master ( cf3172...387a64 )
by John
04:56
created
app/Http/Controllers/Ajax/ProblemController.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
         if (empty($basic)) {
111 111
             return ResponseModel::err(3001);
112 112
         }
113
-        $ret=$problemModel->addSolution($pid,Auth::user()->id,$content);
114
-        return $ret?ResponseModel::success(200):ResponseModel::err(3003);
113
+        $ret=$problemModel->addSolution($pid, Auth::user()->id, $content);
114
+        return $ret ?ResponseModel::success(200) : ResponseModel::err(3003);
115 115
     }
116 116
     /**
117 117
      * The Ajax Problem Solution Discussion Update.
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
         $problemModel=new ProblemModel();
127 127
         $psoid=$all_data["psoid"];
128 128
         $content=$all_data["content"];
129
-        $ret=$problemModel->updateSolution($psoid,Auth::user()->id,$content);
130
-        return $ret?ResponseModel::success(200):ResponseModel::err(3004);
129
+        $ret=$problemModel->updateSolution($psoid, Auth::user()->id, $content);
130
+        return $ret ?ResponseModel::success(200) : ResponseModel::err(3004);
131 131
     }
132 132
     /**
133 133
      * The Ajax Problem Solution Discussion Delete.
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
         $all_data=$request->all();
142 142
         $problemModel=new ProblemModel();
143 143
         $psoid=$all_data["psoid"];
144
-        $ret=$problemModel->removeSolution($psoid,Auth::user()->id);
145
-        return $ret?ResponseModel::success(200):ResponseModel::err(3004);
144
+        $ret=$problemModel->removeSolution($psoid, Auth::user()->id);
145
+        return $ret ?ResponseModel::success(200) : ResponseModel::err(3004);
146 146
     }
147 147
     /**
148 148
      * The Ajax Problem Solution Discussion Vote.
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
         $problemModel=new ProblemModel();
158 158
         $psoid=$all_data["psoid"];
159 159
         $type=$all_data["type"];
160
-        $ret=$problemModel->voteSolution($psoid,Auth::user()->id,$type);
161
-        return $ret["ret"]?ResponseModel::success(200,null,["votes"=>$ret["votes"],"select"=>$ret["select"]]):ResponseModel::err(3004);
160
+        $ret=$problemModel->voteSolution($psoid, Auth::user()->id, $type);
161
+        return $ret["ret"] ?ResponseModel::success(200, null, ["votes"=>$ret["votes"], "select"=>$ret["select"]]) : ResponseModel::err(3004);
162 162
     }
163 163
     /**
164 164
      * The Ajax Problem Solution Submit.
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
         if (empty($basic)) {
253 253
             return ResponseModel::err(3001);
254 254
         }
255
-        $ret=$problemModel->addDiscussion(Auth::user()->id,$pid,$title,$content);
256
-        return $ret?ResponseModel::success(200, null, $ret):ResponseModel::err(3003);
255
+        $ret=$problemModel->addDiscussion(Auth::user()->id, $pid, $title, $content);
256
+        return $ret ?ResponseModel::success(200, null, $ret) : ResponseModel::err(3003);
257 257
     }
258 258
 
259 259
     public function addComment(Request $request)
@@ -272,8 +272,8 @@  discard block
 block discarded – undo
272 272
         if (empty($basic)) {
273 273
             return ResponseModel::err(3001);
274 274
         }
275
-        $ret=$problemModel->addComment(Auth::user()->id,$pdid,$content,$reply_id);
276
-        return $ret?ResponseModel::success(200, null, $ret):ResponseModel::err(3003);
275
+        $ret=$problemModel->addComment(Auth::user()->id, $pdid, $content, $reply_id);
276
+        return $ret ?ResponseModel::success(200, null, $ret) : ResponseModel::err(3003);
277 277
     }
278 278
   
279 279
     /**
@@ -292,15 +292,15 @@  discard block
 block discarded – undo
292 292
 
293 293
         $submissionData=$submissionModel->basic($all_data["sid"]);
294 294
 
295
-        if($submissionData["uid"]!=Auth::user()->id){
295
+        if ($submissionData["uid"]!=Auth::user()->id) {
296 296
             return ResponseModel::err(2001);
297 297
         }
298 298
 
299
-        if($submissionData["verdict"]!="Submission Error"){
299
+        if ($submissionData["verdict"]!="Submission Error") {
300 300
             return ResponseModel::err(6003);
301 301
         }
302 302
 
303
-        $submissionModel->updateSubmission($all_data["sid"],[
303
+        $submissionModel->updateSubmission($all_data["sid"], [
304 304
             "verdict"=>"Pending",
305 305
             "time"=>0,
306 306
             "memory"=>0
Please login to merge, or discard this patch.
app/Models/GroupModel.php 1 patch
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
         foreach ($trending_groups as &$t) {
58 58
             $t["members"]=$this->countGroupMembers($t["gid"]);
59 59
         }
60
-        usort($trending_groups, function ($a, $b) {
60
+        usort($trending_groups, function($a, $b) {
61 61
             return $b["members"]<=>$a["members"];
62 62
         });
63
-        Cache::tags(['group'])->put('trending', array_slice($trending_groups,0,12), 3600*24);
63
+        Cache::tags(['group'])->put('trending', array_slice($trending_groups, 0, 12), 3600 * 24);
64 64
     }
65 65
 
66 66
     public function userGroups($uid)
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 
101 101
     public function changeGroupName($gid, $GroupName)
102 102
     {
103
-        return DB::table("group")->where('gid',$gid)->update([
103
+        return DB::table("group")->where('gid', $gid)->update([
104 104
             "name"=>$GroupName
105 105
         ]);
106 106
     }
107 107
 
108
-    public function changeJoinPolicy($gid, $JoinPolicy){
109
-        return DB::table("group")->where('gid',$gid)->update([
108
+    public function changeJoinPolicy($gid, $JoinPolicy) {
109
+        return DB::table("group")->where('gid', $gid)->update([
110 110
             "join_policy"=>$JoinPolicy
111 111
         ]);
112 112
     }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     public function details($gcode)
121 121
     {
122 122
         $basic_info=DB::table($this->tableName)->where(["gcode"=>$gcode])->first();
123
-        if(empty($basic_info)) return [];
123
+        if (empty($basic_info)) return [];
124 124
         $basic_info["members"]=$this->countGroupMembers($basic_info["gid"]);
125 125
         $basic_info["tags"]=$this->getGroupTags($basic_info["gid"]);
126 126
         $basic_info["create_time_foramt"]=date_format(date_create($basic_info["create_time"]), 'M jS, Y');
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
     public function userProfile($uid, $gid)
138 138
     {
139 139
         $info=DB::table("group_member")
140
-        ->join('users','users.id','=','group_member.uid')
140
+        ->join('users', 'users.id', '=', 'group_member.uid')
141 141
         ->where(["gid"=>$gid, "uid"=>$uid])
142 142
         ->where("role", ">", 0)
143
-        ->select('avatar','describes','email','gid','uid','name','nick_name','professional_rate','role','sub_group')
143
+        ->select('avatar', 'describes', 'email', 'gid', 'uid', 'name', 'nick_name', 'professional_rate', 'role', 'sub_group')
144 144
         ->first();
145 145
         if (!empty($info)) {
146 146
             $info["role_parsed"]=$this->role[$info["role"]];
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         foreach ($user_list as &$u) {
169 169
             $u["role_parsed"]=$this->role[$u["role"]];
170 170
             $u["role_color"]=$this->role_color[$u["role"]];
171
-            if(is_null($u["sub_group"])) $u["sub_group"]="None";
171
+            if (is_null($u["sub_group"])) $u["sub_group"]="None";
172 172
         }
173 173
         return $user_list;
174 174
     }
@@ -229,16 +229,16 @@  discard block
 block discarded – undo
229 229
         ])->where("role", ">", 0)->count();
230 230
     }
231 231
 
232
-    public function problemTags($gid,$pid = -1)
232
+    public function problemTags($gid, $pid=-1)
233 233
     {
234
-        if($pid == -1){
235
-            $tags =  DB::table('group_problem_tag')
234
+        if ($pid==-1) {
235
+            $tags=DB::table('group_problem_tag')
236 236
             ->select('tag')
237
-            ->where('gid',$gid)
237
+            ->where('gid', $gid)
238 238
             ->distinct()
239 239
             ->get()->all();
240
-        }else{
241
-            $tags =  DB::table('group_problem_tag')
240
+        } else {
241
+            $tags=DB::table('group_problem_tag')
242 242
             ->select('tag')
243 243
             ->where('gid', $gid)
244 244
             ->where('pid', $pid)
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
             ->get()->all();
247 247
         }
248 248
 
249
-        $tags_arr = [];
250
-        if(!empty($tags)){
249
+        $tags_arr=[];
250
+        if (!empty($tags)) {
251 251
             foreach ($tags as $value) {
252
-                array_push($tags_arr,$value['tag']);
252
+                array_push($tags_arr, $value['tag']);
253 253
             }
254 254
         }
255 255
         return $tags_arr;
@@ -257,28 +257,28 @@  discard block
 block discarded – undo
257 257
 
258 258
     public function problems($gid)
259 259
     {
260
-        $contestModel = new ContestModel();
261
-        $problems = DB::table('contest_problem')
262
-        ->join('contest','contest_problem.cid', '=', 'contest.cid')
263
-        ->join('problem','contest_problem.pid', '=', 'problem.pid' )
260
+        $contestModel=new ContestModel();
261
+        $problems=DB::table('contest_problem')
262
+        ->join('contest', 'contest_problem.cid', '=', 'contest.cid')
263
+        ->join('problem', 'contest_problem.pid', '=', 'problem.pid')
264 264
         ->select('contest_problem.cid as cid', 'problem.pid as pid', 'pcode', 'title')
265
-        ->where('contest.gid',$gid)
266
-        ->where('contest.practice',1)
267
-        ->orderBy('contest.create_time','desc')
265
+        ->where('contest.gid', $gid)
266
+        ->where('contest.practice', 1)
267
+        ->orderBy('contest.create_time', 'desc')
268 268
         ->distinct()
269 269
         ->get()->all();
270
-        $user_id = Auth::user()->id;
271
-        foreach($problems as $key => $value){
272
-            if($contestModel->judgeClearance($value['cid'],$user_id) != 3){
270
+        $user_id=Auth::user()->id;
271
+        foreach ($problems as $key => $value) {
272
+            if ($contestModel->judgeClearance($value['cid'], $user_id)!=3) {
273 273
                 unset($problems[$key]);
274
-            }else{
275
-                $problems[$key]['tags'] = $this->problemTags($gid,$value['pid']);
274
+            } else {
275
+                $problems[$key]['tags']=$this->problemTags($gid, $value['pid']);
276 276
             }
277 277
         }
278 278
         return $problems;
279 279
     }
280 280
 
281
-    public function problemAddTag($gid,$pid,$tag)
281
+    public function problemAddTag($gid, $pid, $tag)
282 282
     {
283 283
         return DB::table("group_problem_tag")->insert([
284 284
             "gid"=>$gid,
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
         ]);
288 288
     }
289 289
 
290
-    public function problemRemoveTag($gid,$pid,$tag)
290
+    public function problemRemoveTag($gid, $pid, $tag)
291 291
     {
292 292
         return DB::table("group_problem_tag")->where([
293 293
             "gid"=>$gid,
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
     public function judgeEmailClearance($gid, $email)
333 333
     {
334 334
         $user=DB::table("users")->where(["email"=>$email])->first();
335
-        if(empty($user)) return -4;
335
+        if (empty($user)) return -4;
336 336
         $ret=DB::table("group_member")->where([
337 337
             "gid"=>$gid,
338 338
             "uid"=>$user["id"],
@@ -423,20 +423,20 @@  discard block
 block discarded – undo
423 423
 
424 424
     public function groupMemberPracticeContestStat($gid)
425 425
     {
426
-        $contestModel = new ContestModel();
426
+        $contestModel=new ContestModel();
427 427
 
428
-        $allPracticeContest = DB::table('contest')
428
+        $allPracticeContest=DB::table('contest')
429 429
             ->where([
430 430
                 'gid' => $gid,
431 431
                 'practice' => 1,
432 432
             ])
433
-            ->select('cid','name')
433
+            ->select('cid', 'name')
434 434
             ->get()->all();
435
-        $user_list = $this->userList($gid);
435
+        $user_list=$this->userList($gid);
436 436
 
437
-        $memberData = [];
437
+        $memberData=[];
438 438
         foreach ($user_list as $u) {
439
-            $memberData[$u['uid']] = [
439
+            $memberData[$u['uid']]=[
440 440
                 'name' => $u['name'],
441 441
                 'nick_name' => $u['nick_name'],
442 442
                 'elo' => $u['ranking'],
@@ -447,61 +447,61 @@  discard block
 block discarded – undo
447 447
             ];
448 448
         }
449 449
         foreach ($allPracticeContest as $c) {
450
-            $contestRankRaw = $contestModel->contestRank($c['cid']);
451
-            foreach($contestRankRaw as $key => $contestRank){
452
-                if(isset($contestRank['remote']) && $contestRank['remote']){
450
+            $contestRankRaw=$contestModel->contestRank($c['cid']);
451
+            foreach ($contestRankRaw as $key => $contestRank) {
452
+                if (isset($contestRank['remote']) && $contestRank['remote']) {
453 453
                     unset($contestRankRaw[$key]);
454 454
                 }
455 455
             }
456
-            $contestRank = array_values($contestRankRaw);
457
-            $problemsCount = DB::table('contest_problem')
458
-                ->where('cid',$c['cid'])
456
+            $contestRank=array_values($contestRankRaw);
457
+            $problemsCount=DB::table('contest_problem')
458
+                ->where('cid', $c['cid'])
459 459
                 ->count();
460
-            $index = 1;
461
-            $rank = 1;
462
-            $last_cr = [];
463
-            $last_rank = 1;
460
+            $index=1;
461
+            $rank=1;
462
+            $last_cr=[];
463
+            $last_rank=1;
464 464
             foreach ($contestRank as $cr) {
465
-                $last_rank = $index;
466
-                if(!empty($last_cr)){
467
-                    if($cr['solved'] == $last_cr['solved'] && $cr['penalty'] == $last_cr['penalty'] ){
468
-                        $rank = $last_rank;
469
-                    }else{
470
-                        $rank = $index;
471
-                        $last_rank = $rank;
465
+                $last_rank=$index;
466
+                if (!empty($last_cr)) {
467
+                    if ($cr['solved']==$last_cr['solved'] && $cr['penalty']==$last_cr['penalty']) {
468
+                        $rank=$last_rank;
469
+                    } else {
470
+                        $rank=$index;
471
+                        $last_rank=$rank;
472 472
                     }
473 473
                 }
474
-                if(in_array($cr['uid'],array_keys($memberData))) {
475
-                    $memberData[$cr['uid']]['solved_all'] += $cr['solved'];
476
-                    $memberData[$cr['uid']]['problem_all'] += $problemsCount;
477
-                    $memberData[$cr['uid']]['penalty'] += $cr['penalty'];
478
-                    $memberData[$cr['uid']]['contest_detial'][$c['cid']] = [
474
+                if (in_array($cr['uid'], array_keys($memberData))) {
475
+                    $memberData[$cr['uid']]['solved_all']+=$cr['solved'];
476
+                    $memberData[$cr['uid']]['problem_all']+=$problemsCount;
477
+                    $memberData[$cr['uid']]['penalty']+=$cr['penalty'];
478
+                    $memberData[$cr['uid']]['contest_detial'][$c['cid']]=[
479 479
                         'rank' => $rank,
480 480
                         'solved' => $cr['solved'],
481 481
                         'problems' => $problemsCount,
482 482
                         'penalty' => $cr['penalty']
483 483
                     ];
484 484
                 }
485
-                $last_cr = $cr;
485
+                $last_cr=$cr;
486 486
                 $index++;
487 487
             }
488 488
         }
489
-        $new_memberData = [];
489
+        $new_memberData=[];
490 490
         foreach ($memberData as $uid => $data) {
491
-            $contest_count = 0;
492
-            $rank_sum = 0;
491
+            $contest_count=0;
492
+            $rank_sum=0;
493 493
             foreach ($data['contest_detial'] as $cid => $c) {
494
-                $rank_sum += $c['rank'];
495
-                $contest_count += 1;
494
+                $rank_sum+=$c['rank'];
495
+                $contest_count+=1;
496 496
             }
497
-            $temp = $data;
498
-            $temp['uid'] = $uid;
499
-            if($contest_count != 0){
500
-                $temp['rank_ave'] = $rank_sum/$contest_count;
497
+            $temp=$data;
498
+            $temp['uid']=$uid;
499
+            if ($contest_count!=0) {
500
+                $temp['rank_ave']=$rank_sum / $contest_count;
501 501
             }
502
-            array_push($new_memberData,$temp);
502
+            array_push($new_memberData, $temp);
503 503
         }
504
-        $ret = [
504
+        $ret=[
505 505
             'contest_list' => $allPracticeContest,
506 506
             'member_data' => $new_memberData
507 507
         ];
@@ -510,58 +510,58 @@  discard block
 block discarded – undo
510 510
 
511 511
     public function groupMemberPracticeTagStat($gid)
512 512
     {
513
-        $tags = $this->problemTags($gid);
514
-        $tag_problems = [];
513
+        $tags=$this->problemTags($gid);
514
+        $tag_problems=[];
515 515
 
516
-        $user_list = $this->userList($gid);
516
+        $user_list=$this->userList($gid);
517 517
         foreach ($tags as $tag) {
518
-            $tag_problems[$tag] = DB::table('problem')
519
-                ->join('group_problem_tag','problem.pid','=','group_problem_tag.pid')
518
+            $tag_problems[$tag]=DB::table('problem')
519
+                ->join('group_problem_tag', 'problem.pid', '=', 'group_problem_tag.pid')
520 520
                 ->where([
521 521
                     'group_problem_tag.gid' => $gid,
522 522
                     'tag' => $tag
523 523
                 ])
524
-                ->select('group_problem_tag.pid as pid','pcode','title')
524
+                ->select('group_problem_tag.pid as pid', 'pcode', 'title')
525 525
                 ->get()->all();
526 526
         }
527
-        $all_problems = [];
527
+        $all_problems=[];
528 528
         foreach ($tag_problems as &$tag_problem_set) {
529 529
             foreach ($tag_problem_set as $problem) {
530
-                $all_problems[$problem['pid']] = $problem;
530
+                $all_problems[$problem['pid']]=$problem;
531 531
             }
532
-            $tag_problem_set = array_column($tag_problem_set,'pid');
532
+            $tag_problem_set=array_column($tag_problem_set, 'pid');
533 533
         }
534
-        $submission_data =  DB::table('submission')
535
-            ->whereIn('pid',array_keys($all_problems))
536
-            ->whereIn('uid',array_column($user_list,'uid'))
537
-            ->where('verdict','Accepted')
538
-            ->select('pid','uid')
534
+        $submission_data=DB::table('submission')
535
+            ->whereIn('pid', array_keys($all_problems))
536
+            ->whereIn('uid', array_column($user_list, 'uid'))
537
+            ->where('verdict', 'Accepted')
538
+            ->select('pid', 'uid')
539 539
             ->get()->all();
540 540
 
541
-        $memberData = [];
541
+        $memberData=[];
542 542
         foreach ($user_list as $member) {
543
-            $completion = [];
544
-            foreach($tag_problems as $tag => $problems) {
545
-                $completion[$tag] = [];
543
+            $completion=[];
544
+            foreach ($tag_problems as $tag => $problems) {
545
+                $completion[$tag]=[];
546 546
                 foreach ($problems as $problem) {
547
-                    $is_accepted = 0;
547
+                    $is_accepted=0;
548 548
                     foreach ($submission_data as $sd) {
549
-                        if($sd['pid'] == $problem && $sd['uid'] == $member['uid']){
550
-                            $is_accepted = 1;
549
+                        if ($sd['pid']==$problem && $sd['uid']==$member['uid']) {
550
+                            $is_accepted=1;
551 551
                             break;
552 552
                         }
553 553
                     }
554
-                    $completion[$tag][$problem] = $is_accepted;
554
+                    $completion[$tag][$problem]=$is_accepted;
555 555
                 }
556 556
             }
557
-            array_push($memberData,[
557
+            array_push($memberData, [
558 558
                 'uid' => $member['uid'],
559 559
                 'name' => $member['name'],
560 560
                 'nick_name' => $member['nick_name'],
561 561
                 'completion' => $completion,
562 562
             ]);
563 563
         }
564
-        $ret = [
564
+        $ret=[
565 565
             'all_problems' => $all_problems,
566 566
             'tag_problems' => $tag_problems,
567 567
             'member_data' => $memberData
@@ -571,10 +571,10 @@  discard block
 block discarded – undo
571 571
 
572 572
     public function refreshAllElo()
573 573
     {
574
-        $result = [];
575
-        $gids = DB::table('group')->select('gid','name')->get()->all();
574
+        $result=[];
575
+        $gids=DB::table('group')->select('gid', 'name')->get()->all();
576 576
         foreach ($gids as $gid) {
577
-            $result[$gid['gid']] = [
577
+            $result[$gid['gid']]=[
578 578
                 'name' => $gid['name'],
579 579
                 'result' => $this->refreshElo($gid['gid']),
580 580
             ];
@@ -585,41 +585,41 @@  discard block
 block discarded – undo
585 585
     public function refreshElo($gid)
586 586
     {
587 587
         DB::table('group_rated_change_log')
588
-            ->where('gid',$gid)
588
+            ->where('gid', $gid)
589 589
             ->delete();
590 590
         DB::table('group_member')
591
-            ->where('gid',$gid)
591
+            ->where('gid', $gid)
592 592
             ->update([
593 593
                 'ranking' => 1500
594 594
             ]);
595
-        $contests = DB::table('contest')
595
+        $contests=DB::table('contest')
596 596
             ->where([
597 597
                 'gid' => $gid,
598 598
                 'practice' => 1
599 599
             ])
600
-            ->where('end_time','<',date("Y-m-d H:i:s"))
601
-            ->select('cid','name')
600
+            ->where('end_time', '<', date("Y-m-d H:i:s"))
601
+            ->select('cid', 'name')
602 602
             ->orderBy('end_time')
603 603
             ->get()->all();
604 604
 
605
-        if(empty($contests)) {
605
+        if (empty($contests)) {
606 606
             return [];
607 607
         }
608
-        $result = [];
609
-        $contestModel = new ContestModel();
608
+        $result=[];
609
+        $contestModel=new ContestModel();
610 610
         foreach ($contests as $contest) {
611
-            $judge_status = $contestModel->judgeOver($contest['cid']);
612
-            if($judge_status['result'] == true){
613
-                $calc = new GroupRatingCalculator($contest['cid']);
611
+            $judge_status=$contestModel->judgeOver($contest['cid']);
612
+            if ($judge_status['result']==true) {
613
+                $calc=new GroupRatingCalculator($contest['cid']);
614 614
                 $calc->calculate();
615 615
                 $calc->storage();
616
-                $result[] = [
616
+                $result[]=[
617 617
                     'ret' => 'success',
618 618
                     'cid' => $contest['cid'],
619 619
                     'name' => $contest['name']
620 620
                 ];
621
-            }else{
622
-                $result[] = [
621
+            } else {
622
+                $result[]=[
623 623
                     'ret' => 'judging',
624 624
                     'cid' => $contest['cid'],
625 625
                     'name' => $contest['name'],
@@ -631,23 +631,23 @@  discard block
 block discarded – undo
631 631
         return $result;
632 632
     }
633 633
 
634
-    public function getEloChangeLog($gid,$uid)
634
+    public function getEloChangeLog($gid, $uid)
635 635
     {
636
-        $ret = DB::table('group_rated_change_log')
637
-            ->join('contest','group_rated_change_log.cid','=','contest.cid')
636
+        $ret=DB::table('group_rated_change_log')
637
+            ->join('contest', 'group_rated_change_log.cid', '=', 'contest.cid')
638 638
             ->where([
639 639
                 'group_rated_change_log.gid' => $gid,
640 640
                 'group_rated_change_log.uid' => $uid
641 641
             ])->select('group_rated_change_log.cid as cid', 'contest.name as name', 'ranking', 'end_time')
642 642
             ->orderBy('contest.end_time')
643 643
             ->get()->all();
644
-            $begin = [
644
+            $begin=[
645 645
                 'cid' => -1,
646 646
                 'name' => '',
647 647
                 'ranking' => '1500',
648
-                'end_time' => date("Y-m-d H:i:s",(strtotime($ret[0]['end_time'] ?? time())  - 3600*24)),
648
+                'end_time' => date("Y-m-d H:i:s", (strtotime($ret[0]['end_time'] ?? time())-3600 * 24)),
649 649
             ];
650
-            $ret = array_prepend($ret,$begin);
650
+            $ret=array_prepend($ret, $begin);
651 651
         return $ret;
652 652
     }
653 653
 }
Please login to merge, or discard this patch.
app/Http/Controllers/Ajax/GroupManageController.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
         $all_data=$request->all();
37 37
 
38
-        if(($all_data['public'] ?? 0) && ($all_data['practice'] ?? 0)){
38
+        if (($all_data['public'] ?? 0) && ($all_data['practice'] ?? 0)) {
39 39
             return ResponseModel::err(4007);
40 40
         }
41 41
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             return ResponseModel::err(1003);
67 67
         }
68 68
 
69
-        $cid = $contestModel->arrangeContest($all_data["gid"], [
69
+        $cid=$contestModel->arrangeContest($all_data["gid"], [
70 70
             "assign_uid"=>Auth::user()->id,
71 71
             "name"=>$all_data["name"],
72 72
             "description"=>$all_data["description"],
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             "public"=>$all_data["public"] ?? 0,
77 77
         ], $problemSet);
78 78
 
79
-        return ResponseModel::success(200,'Successful!',$cid);
79
+        return ResponseModel::success(200, 'Successful!', $cid);
80 80
     }
81 81
 
82 82
     public function changeGroupName(Request $request)
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
         $groupModel=new GroupModel();
92 92
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
93
-        if ($clearance < 2){
93
+        if ($clearance<2) {
94 94
             return ResponseModel::err(2001);
95 95
         }
96 96
 
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 
110 110
         $groupModel=new GroupModel();
111 111
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
112
-        if ($clearance < 2){
112
+        if ($clearance<2) {
113 113
             return ResponseModel::err(2001);
114 114
         }
115 115
 
116
-        if ($all_data["join_policy"] < 1 || $all_data["join_policy"] > 3){
116
+        if ($all_data["join_policy"]<1 || $all_data["join_policy"]>3) {
117 117
             return ResponseModel::err(1007);
118 118
         }
119 119
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             'gid' => 'required|integer',
128 128
         ]);
129 129
 
130
-        $all_data = $request->all();
130
+        $all_data=$request->all();
131 131
 
132 132
         if (!empty($request->file('img')) && $request->file('img')->isValid()) {
133 133
             $extension=$request->file('img')->extension();
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
         $groupModel=new GroupModel();
141 141
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
142
-        if ($clearance < 2){
142
+        if ($clearance<2) {
143 143
             return ResponseModel::err(2001);
144 144
         }
145 145
 
@@ -177,18 +177,18 @@  discard block
 block discarded – undo
177 177
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
178 178
         $target_clearance=$groupModel->judgeClearance($all_data["gid"], $all_data['uid']);
179 179
 
180
-        if($target_clearance == -3){
180
+        if ($target_clearance==-3) {
181 181
             return ResponseModel::err(7004);
182 182
         }
183 183
 
184
-        if($target_clearance >= $clearance || $clearance < 2 || $all_data['permission'] >= $clearance){
184
+        if ($target_clearance>=$clearance || $clearance<2 || $all_data['permission']>=$clearance) {
185 185
             return ResponseModel::err(2001);
186 186
         }
187 187
 
188 188
         $groupModel->changeClearance($all_data['uid'], $all_data["gid"], $all_data['permission']);
189 189
 
190
-        $result_info = $groupModel->userProfile($all_data['uid'],$all_data["gid"]);
191
-        return ResponseModel::success(200,null,$result_info);
190
+        $result_info=$groupModel->userProfile($all_data['uid'], $all_data["gid"]);
191
+        return ResponseModel::success(200, null, $result_info);
192 192
     }
193 193
 
194 194
     public function approveMember(Request $request)
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
205 205
         $targetClearance=$groupModel->judgeClearance($all_data["gid"], $all_data["uid"]);
206 206
         if ($clearance>1) {
207
-            if($targetClearance!=0) {
207
+            if ($targetClearance!=0) {
208 208
                 return ResponseModel::err(7003);
209 209
             }
210 210
             $groupModel->changeClearance($all_data["uid"], $all_data["gid"], 1);
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         $groupModel=new GroupModel();
226 226
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
227 227
         $targetClearance=$groupModel->judgeClearance($all_data["gid"], $all_data["uid"]);
228
-        if ($clearance <= 1 || $clearance <= $targetClearance){
228
+        if ($clearance<=1 || $clearance<=$targetClearance) {
229 229
             return ResponseModel::err(7002);
230 230
         }
231 231
 
@@ -245,16 +245,16 @@  discard block
 block discarded – undo
245 245
 
246 246
         $groupModel=new GroupModel();
247 247
         $is_user=$groupModel->isUser($all_data["email"]);
248
-        if(!$is_user) return ResponseModel::err(2006);
248
+        if (!$is_user) return ResponseModel::err(2006);
249 249
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
250
-        if($clearance<2) return ResponseModel::err(7002);
250
+        if ($clearance<2) return ResponseModel::err(7002);
251 251
         $targetClearance=$groupModel->judgeEmailClearance($all_data["gid"], $all_data["email"]);
252
-        if($targetClearance!=-3) return ResponseModel::err(7003);
252
+        if ($targetClearance!=-3) return ResponseModel::err(7003);
253 253
         $groupModel->inviteMember($all_data["gid"], $all_data["email"]);
254
-        $basic = $groupModel->basic($all_data['gid']);
255
-        $url = route('group.detail',['gcode' => $basic['gcode']]);
256
-        $receiverInfo = UserModel::where('email',$all_data['email'])->first();
257
-        $sender_name = Auth::user()->name;
254
+        $basic=$groupModel->basic($all_data['gid']);
255
+        $url=route('group.detail', ['gcode' => $basic['gcode']]);
256
+        $receiverInfo=UserModel::where('email', $all_data['email'])->first();
257
+        $sender_name=Auth::user()->name;
258 258
         sendMessage([
259 259
             'receiver' => $receiverInfo["id"],
260 260
             'sender' => Auth::user()->id,
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 
297 297
         $groupModel=new GroupModel();
298 298
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
299
-        if ($clearance < 2){
299
+        if ($clearance<2) {
300 300
             return ResponseModel::err(2001);
301 301
         }
302 302
         $groupModel->createNotice($all_data["gid"], Auth::user()->id, $all_data["title"], $all_data["content"]);
Please login to merge, or discard this patch.
app/Admin/Controllers/BabelController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     {
91 91
         $extensionList=ExtensionModel::list();
92 92
 
93
-        if(empty($extensionList)){
93
+        if (empty($extensionList)) {
94 94
             return view('admin::babel.empty');
95 95
         }
96 96
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     {
104 104
         $details=ExtensionModel::remoteDetail($code);
105 105
 
106
-        if(empty($details)){
106
+        if (empty($details)) {
107 107
             return view('admin::babel.empty');
108 108
         }
109 109
 
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
 
115 115
     private static function executeArtisan($command)
116 116
     {
117
-        $fp = popen('php "'.base_path('artisan').'" '.$command, "r");
118
-        while($b = fgets($fp, 2048)) {
117
+        $fp=popen('php "'.base_path('artisan').'" '.$command, "r");
118
+        while ($b=fgets($fp, 2048)) {
119 119
             echo str_pad(json_encode([
120 120
                 "ret"=>200,
121 121
                 "desc"=>"Succeed",
122 122
                 "data"=>[
123 123
                     "message"=>$b
124 124
                 ]
125
-            ])."\n",4096);
125
+            ])."\n", 4096);
126 126
             @ob_flush();
127 127
             flush();
128 128
         }
Please login to merge, or discard this patch.