Passed
Push — master ( affb10...b25042 )
by John
18:32 queued 13:30
created
app/Http/Middleware/User/Banned.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,25 +17,25 @@
 block discarded – undo
17 17
     public function handle($request, Closure $next)
18 18
     {
19 19
         //check login
20
-        if(!Auth::check()){
20
+        if (!Auth::check()) {
21 21
             return $next($request);
22 22
         }
23
-        $user = Auth::user();
24
-        $banned = $user->banneds()->orderBy('removed_at', 'desc')->first();
23
+        $user=Auth::user();
24
+        $banned=$user->banneds()->orderBy('removed_at', 'desc')->first();
25 25
         //check if there are any banned records
26
-        if(empty($banned)) {
26
+        if (empty($banned)) {
27 27
             return $next($request);
28 28
         }
29 29
         //check the time of the last record
30
-        if(strtotime($banned->removed_at) <= time()){
30
+        if (strtotime($banned->removed_at)<=time()) {
31 31
             return $next($request);
32 32
         }
33 33
         //return error page
34
-        if($request->method() == 'GET'){
35
-            return response()->view('errors.451',[
34
+        if ($request->method()=='GET') {
35
+            return response()->view('errors.451', [
36 36
                 'description' => "Your account is currently blocked and will remain so until {$banned->removed_at}. Here's why: {$banned->reason}",
37 37
             ]);
38
-        }else{
38
+        } else {
39 39
             return response()->json([
40 40
                 'ret' => 451,
41 41
                 'desc' => 'Unavailable For Legal Reasons',
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
             return response()->view('errors.451',[
36 36
                 'description' => "Your account is currently blocked and will remain so until {$banned->removed_at}. Here's why: {$banned->reason}",
37 37
             ]);
38
-        }else{
38
+        } else{
39 39
             return response()->json([
40 40
                 'ret' => 451,
41 41
                 'desc' => 'Unavailable For Legal Reasons',
Please login to merge, or discard this patch.
app/Http/Middleware/Group/Banned.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@
 block discarded – undo
17 17
      */
18 18
     public function handle($request, Closure $next)
19 19
     {
20
-        $gcode = $request->gcode;
21
-        $group = Group::where('gcode',$gcode)->first();
22
-        $banneds = $group->banneds()->where('removed_at','>',date('Y-m-d H:i:s'))->first();
23
-        $user = Auth::user();
24
-        if(!empty($banneds) && $user->id != $group->leader->id) {
25
-            return response()->view('errors.451',[
20
+        $gcode=$request->gcode;
21
+        $group=Group::where('gcode', $gcode)->first();
22
+        $banneds=$group->banneds()->where('removed_at', '>', date('Y-m-d H:i:s'))->first();
23
+        $user=Auth::user();
24
+        if (!empty($banneds) && $user->id!=$group->leader->id) {
25
+            return response()->view('errors.451', [
26 26
                 'description' => 'This group is currently banned. Please contact the group administrator.'
27 27
             ]);
28 28
         }
Please login to merge, or discard this patch.
app/Http/Middleware/Group/Exists.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@
 block discarded – undo
16 16
      */
17 17
     public function handle($request, Closure $next)
18 18
     {
19
-        $gcode = $request->gcode;
20
-        $group = Group::where('gcode',$gcode)->first();
21
-        if(!empty($group)){
19
+        $gcode=$request->gcode;
20
+        $group=Group::where('gcode', $gcode)->first();
21
+        if (!empty($group)) {
22 22
             return $next($request);
23
-        }else{
23
+        } else {
24 24
             return redirect('/group');
25 25
         }
26 26
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
         $group = Group::where('gcode',$gcode)->first();
21 21
         if(!empty($group)){
22 22
             return $next($request);
23
-        }else{
23
+        } else{
24 24
             return redirect('/group');
25 25
         }
26 26
 
Please login to merge, or discard this patch.
app/Admin/Controllers/AbuseController.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      *
24 24
      * @var string
25 25
      */
26
-    protected $title = 'Abuses';
26
+    protected $title='Abuses';
27 27
 
28 28
     /**
29 29
      * Make a grid builder.
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      */
33 33
     protected function grid()
34 34
     {
35
-        $grid = new Grid(new Abuse);
35
+        $grid=new Grid(new Abuse);
36 36
 
37 37
         $grid->column('id', __('Id'));
38 38
         $grid->column('title', __('Title'));
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      */
59 59
     protected function detail($id)
60 60
     {
61
-        $show = new Show(Abuse::findOrFail($id));
61
+        $show=new Show(Abuse::findOrFail($id));
62 62
 
63 63
         $show->field('id', __('Id'));
64 64
         $show->field('title', __('Title'));
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     protected function form()
83 83
     {
84
-        $form = new Form(new Abuse);
84
+        $form=new Form(new Abuse);
85 85
 
86 86
         $form->text('title', __('Title'));
87 87
         $form->number('cause', __('Cause'));
@@ -92,23 +92,23 @@  discard block
 block discarded – undo
92 92
 
93 93
         $form->ignore(['created_at']);
94 94
 
95
-        $form->saving(function (Form $form) {
96
-            $abuse = $form->model();
95
+        $form->saving(function(Form $form) {
96
+            $abuse=$form->model();
97 97
             //get gategory and subject id
98
-            $regex = '/^([A-Za-z]+) #(\d+)/';
99
-            $matches = [];
100
-            preg_match($regex,$abuse->title,$matches);
101
-            $category = array_search(strtolower($matches[1]),Abuse::$supportCategory);
102
-            $subject_id = (int)$matches[2];
103
-            switch($abuse->category) {
98
+            $regex='/^([A-Za-z]+) #(\d+)/';
99
+            $matches=[];
100
+            preg_match($regex, $abuse->title, $matches);
101
+            $category=array_search(strtolower($matches[1]), Abuse::$supportCategory);
102
+            $subject_id=(int) $matches[2];
103
+            switch ($abuse->category) {
104 104
                 case 0:
105
-                    $gid = $subject_id;
106
-                    $group = Group::find($gid);
107
-                    if(empty($group)) {
108
-                        return ;
105
+                    $gid=$subject_id;
106
+                    $group=Group::find($gid);
107
+                    if (empty($group)) {
108
+                        return;
109 109
                     }
110
-                    if($form->audit) {
111
-                        $ban_time = request()->created_at;
110
+                    if ($form->audit) {
111
+                        $ban_time=request()->created_at;
112 112
                         sendMessage([
113 113
                             'sender'    => 1,
114 114
                             'receiver'  => $abuse->user_id,
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
                             'reason'     => $abuse->supplement,
129 129
                             'removed_at' => $ban_time
130 130
                         ]);
131
-                        return ;
132
-                    }else{
131
+                        return;
132
+                    } else {
133 133
                         sendMessage([
134 134
                             'sender'    => 1,
135 135
                             'receiver'  => $abuse->user_id,
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
                             'content'   => "Hi, Dear **{$abuse->user->name}**,\n\n We have checked your Abuse report about group **[{$group->name}]({$group->link})**.\n\n However, we regret to say that the information you submitted is not sufficient for us to take action.\n\n Of course, we will continue to follow up the investigation.\n\n Thank you for your contribution to our community environment.\n\n Sincerely, NOJ"
138 138
                         ]);
139 139
                         $abuse->delete();
140
-                        return ;
140
+                        return;
141 141
                     }
142 142
                     return;
143 143
                 case 1:
144
-                    $ban_time = request()->created_at;
144
+                    $ban_time=request()->created_at;
145 145
                     UserBanned::create([
146 146
                         'abuse_id'   => $abuse->id,
147 147
                         'user_id'    => $subject_id,
@@ -170,15 +170,15 @@  discard block
 block discarded – undo
170 170
 
171 171
     protected function check_form()
172 172
     {
173
-        $form = new Form(new Abuse);
174
-        $form->display('id',__('Abuse id'));
173
+        $form=new Form(new Abuse);
174
+        $form->display('id', __('Abuse id'));
175 175
         $form->display('title', __('Title'));
176 176
         $form->display('cause', __('Cause'));
177 177
         $form->display('supplement', __('Supplement'));
178 178
         $form->display('link', __('Group Link'));
179 179
         $form->display('user_id', __('Submitter'));
180
-        $form->radio('audit','result')->options(['0' => 'Reject', '1'=> 'Pass']);
181
-        $form->datetime('created_at','ban until');
180
+        $form->radio('audit', 'result')->options(['0' => 'Reject', '1'=> 'Pass']);
181
+        $form->datetime('created_at', 'ban until');
182 182
 
183 183
         return $form;
184 184
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@
 block discarded – undo
129 129
                             'removed_at' => $ban_time
130 130
                         ]);
131 131
                         return ;
132
-                    }else{
132
+                    } else{
133 133
                         sendMessage([
134 134
                             'sender'    => 1,
135 135
                             'receiver'  => $abuse->user_id,
Please login to merge, or discard this patch.
app/Admin/routes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
     $router->resource('groups', GroupController::class);
21 21
     $router->resource('abuses', AbuseController::class);
22 22
 
23
-    Route::group(['prefix' => 'babel'], function (Router $router) {
23
+    Route::group(['prefix' => 'babel'], function(Router $router) {
24 24
         $router->get('/', 'BabelController@index')->name('admin.babel.index');
25 25
         $router->get('installed', 'BabelController@installed')->name('admin.babel.installed');
26 26
         $router->get('marketspace', 'BabelController@marketspace')->name('admin.babel.marketspace');
Please login to merge, or discard this patch.
app/Admin/Forms/ImportPOEM.php 2 patches
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
      *
18 18
      * @var string
19 19
      */
20
-    public $title = 'Import';
20
+    public $title='Import';
21 21
 
22 22
     /**
23 23
      * Handle the form request.
@@ -28,29 +28,29 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function handle(Request $request)
30 30
     {
31
-        $err = function ($msg) {
32
-            $error = new MessageBag([
31
+        $err=function($msg) {
32
+            $error=new MessageBag([
33 33
                 'title'   => 'POEM parse failed.',
34 34
                 'message' => $msg,
35 35
             ]);
36 36
             return back()->with(compact('error'));
37 37
         };
38
-        $success_message = '';
38
+        $success_message='';
39 39
 
40
-        $file = $request->file('Files');
41
-        if(!$file->isValid()){
40
+        $file=$request->file('Files');
41
+        if (!$file->isValid()) {
42 42
             $err('Invalid POEM files');
43 43
         }
44 44
 
45
-        $path      = $file->getRealPath();
46
-        $poetryRaw = file_get_contents($path);
47
-        $parser    = new POEMParser();
48
-        $poem      = $parser->parse($poetryRaw);
49
-        if(empty($poem)){
45
+        $path=$file->getRealPath();
46
+        $poetryRaw=file_get_contents($path);
47
+        $parser=new POEMParser();
48
+        $poem=$parser->parse($poetryRaw);
49
+        if (empty($poem)) {
50 50
             $err('Malformed POEM files');
51 51
         }
52 52
 
53
-        $success_message .= "
53
+        $success_message.="
54 54
             POEM standard : {$poem['standard']} <br />
55 55
             generator : {$poem['generator']} <br />
56 56
             url : {$poem['url']} <br />
@@ -58,31 +58,31 @@  discard block
 block discarded – undo
58 58
             problems: <br />
59 59
         ";
60 60
 
61
-        $memory_unit = [
61
+        $memory_unit=[
62 62
             'kb' => 1,
63 63
             'mb' => 1024,
64
-            'gb' => 1024*1024
64
+            'gb' => 1024 * 1024
65 65
         ];
66
-        $time_unit = [
66
+        $time_unit=[
67 67
             'ms' => 1,
68 68
             's' => 1000,
69 69
             'm' => 60000,
70 70
             'h' => 3600000
71 71
         ];
72 72
 
73
-        $prefix = 'NOJ';
74
-        $p = ProblemModel::where('pcode','like',$prefix.'%')->orderBy('pcode','desc')->select('pcode')->first();
75
-        if(empty($p)){
76
-            $count = 1000;
77
-        }else{
78
-            $count = (int) str_replace($prefix,'',$p['pcode']);
73
+        $prefix='NOJ';
74
+        $p=ProblemModel::where('pcode', 'like', $prefix.'%')->orderBy('pcode', 'desc')->select('pcode')->first();
75
+        if (empty($p)) {
76
+            $count=1000;
77
+        } else {
78
+            $count=(int) str_replace($prefix, '', $p['pcode']);
79 79
         }
80 80
 
81 81
         foreach ($poem['problems'] as $problem) {
82 82
             //insert problem
83
-            $title = $problem['title'];
84
-            $pro = [
85
-                'pcode'        => $prefix . (++$count),
83
+            $title=$problem['title'];
84
+            $pro=[
85
+                'pcode'        => $prefix.(++$count),
86 86
                 'solved_count' => 0,
87 87
                 'difficulty'   => -1,
88 88
                 'file'         => 0,
@@ -101,49 +101,49 @@  discard block
 block discarded – undo
101 101
                 'force_raw'    => $problem['extra']['forceRaw'],
102 102
                 'partial'      => $problem['extra']['partial']
103 103
             ];
104
-            $pid = ProblemModel::insertGetId($pro);
104
+            $pid=ProblemModel::insertGetId($pro);
105 105
 
106 106
             //migrate sample
107
-            $sample_count = 0;
108
-            foreach($problem['sample'] as $sample){
109
-                $sam = [
107
+            $sample_count=0;
108
+            foreach ($problem['sample'] as $sample) {
109
+                $sam=[
110 110
                     'pid'           => $pid,
111 111
                     'sample_input'  => $sample['input'],
112 112
                     'sample_output' => $sample['output'],
113 113
                 ];
114
-                $psid = DB::table('problem_sample')->insert($sam);
115
-                $sample_count += 1;
114
+                $psid=DB::table('problem_sample')->insert($sam);
115
+                $sample_count+=1;
116 116
             }
117 117
 
118 118
             //create test case file
119
-            if(Storage::exists(storage_path().'/test_case/'.$pro['pcode'])){
119
+            if (Storage::exists(storage_path().'/test_case/'.$pro['pcode'])) {
120 120
                 Storage::deleteDirectory(storage_path().'/test_case/'.$pro['pcode']);
121 121
             }
122 122
             Storage::makeDirectory(storage_path().'/test_case/'.$pro['pcode']);
123
-            $test_case_count = 0;
124
-            $test_case_info = [
123
+            $test_case_count=0;
124
+            $test_case_info=[
125 125
                 'spj'        => false,
126 126
                 'test_cases' => []
127 127
             ];
128
-            foreach($problem['testCases'] as $test_case){
129
-                $test_case_count += 1;
130
-                $test_case_arr = [
128
+            foreach ($problem['testCases'] as $test_case) {
129
+                $test_case_count+=1;
130
+                $test_case_arr=[
131 131
                     'input_name'  => "data{$test_case_count}.in",
132 132
                     'output_name' => "data{$test_case_count}.out",
133 133
                     'input_size'  => strlen($test_case['input']),
134 134
                     'output_size' => strlen($test_case['output']),
135 135
                     'stripped_output_md5' => md5(trim($test_case['output']))
136 136
                 ];
137
-                array_push($test_case_info['test_cases'],$test_case_arr);
137
+                array_push($test_case_info['test_cases'], $test_case_arr);
138 138
                 Storage::disk('test_case')->put('/'.$pro['pcode'].'/'.$test_case_arr['input_name'], $test_case['input']);
139 139
                 Storage::disk('test_case')->put('/'.$pro['pcode'].'/'.$test_case_arr['output_name'], $test_case['output']);
140 140
             }
141 141
             Storage::disk('test_case')->put('/'.$pro['pcode'].'/info', json_encode($test_case_info));
142 142
 
143 143
             //migrate solutions
144
-            $solution_count = 0;
145
-            foreach($problem['solution'] as $solution) {
146
-                $s = [
144
+            $solution_count=0;
145
+            foreach ($problem['solution'] as $solution) {
146
+                $s=[
147 147
                     'uid' => 1,
148 148
                     'pid' => $pid,
149 149
                     'content' => '``` '.$solution['source'],
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
                     'created_at' => date('Y-m-d H:i:s')
153 153
                 ];
154 154
                 DB::table('problem_solution')->insert($s);
155
-                $solution_count += 1;
155
+                $solution_count+=1;
156 156
             }
157 157
 
158
-            $success_message .= '&nbsp;&nbsp;&nbsp;&nbsp;'.
158
+            $success_message.='&nbsp;&nbsp;&nbsp;&nbsp;'.
159 159
                 $pro['pcode'].': "
160 160
                 '.$title.'" with
161 161
                 '.$sample_count.' samples,
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
                 '.$solution_count.' solutions
164 164
                 <br />';
165 165
         }
166
-        admin_success('Import successfully',$success_message);
166
+        admin_success('Import successfully', $success_message);
167 167
         return back();
168 168
     }
169 169
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@
 block discarded – undo
74 74
         $p = ProblemModel::where('pcode','like',$prefix.'%')->orderBy('pcode','desc')->select('pcode')->first();
75 75
         if(empty($p)){
76 76
             $count = 1000;
77
-        }else{
77
+        } else{
78 78
             $count = (int) str_replace($prefix,'',$p['pcode']);
79 79
         }
80 80
 
Please login to merge, or discard this patch.
app/Models/GroupModel.php 2 patches
Braces   +13 added lines, -7 removed lines patch added patch discarded remove patch
@@ -121,7 +121,9 @@  discard block
 block discarded – undo
121 121
     public function details($gcode)
122 122
     {
123 123
         $basic_info=DB::table($this->tableName)->where(["gcode"=>$gcode])->first();
124
-        if(empty($basic_info)) return [];
124
+        if(empty($basic_info)) {
125
+            return [];
126
+        }
125 127
         $basic_info["members"]=$this->countGroupMembers($basic_info["gid"]);
126 128
         $basic_info["tags"]=$this->getGroupTags($basic_info["gid"]);
127 129
         $basic_info["create_time_foramt"]=date_format(date_create($basic_info["created_at"]), 'M jS, Y');
@@ -169,7 +171,9 @@  discard block
 block discarded – undo
169 171
         foreach ($user_list as &$u) {
170 172
             $u["role_parsed"]=$this->role[$u["role"]];
171 173
             $u["role_color"]=$this->role_color[$u["role"]];
172
-            if(is_null($u["sub_group"])) $u["sub_group"]="None";
174
+            if(is_null($u["sub_group"])) {
175
+                $u["sub_group"]="None";
176
+            }
173 177
         }
174 178
         return $user_list;
175 179
     }
@@ -238,7 +242,7 @@  discard block
 block discarded – undo
238 242
             ->where('gid',$gid)
239 243
             ->distinct()
240 244
             ->get()->all();
241
-        }else{
245
+        } else{
242 246
             $tags =  DB::table('group_problem_tag')
243 247
             ->select('tag')
244 248
             ->where('gid', $gid)
@@ -272,7 +276,7 @@  discard block
 block discarded – undo
272 276
         foreach($problems as $key => $value){
273 277
             if($contestModel->judgeClearance($value['cid'],$user_id) != 3){
274 278
                 unset($problems[$key]);
275
-            }else{
279
+            } else{
276 280
                 $problems[$key]['tags'] = $this->problemTags($gid,$value['pid']);
277 281
             }
278 282
         }
@@ -333,7 +337,9 @@  discard block
 block discarded – undo
333 337
     public function judgeEmailClearance($gid, $email)
334 338
     {
335 339
         $user=DB::table("users")->where(["email"=>$email])->first();
336
-        if(empty($user)) return -4;
340
+        if(empty($user)) {
341
+            return -4;
342
+        }
337 343
         $ret=DB::table("group_member")->where([
338 344
             "gid"=>$gid,
339 345
             "uid"=>$user["id"],
@@ -467,7 +473,7 @@  discard block
 block discarded – undo
467 473
                 if(!empty($last_cr)){
468 474
                     if($cr['solved'] == $last_cr['solved'] && $cr['penalty'] == $last_cr['penalty'] ){
469 475
                         $rank = $last_rank;
470
-                    }else{
476
+                    } else{
471 477
                         $rank = $index;
472 478
                         $last_rank = $rank;
473 479
                     }
@@ -619,7 +625,7 @@  discard block
 block discarded – undo
619 625
                     'cid' => $contest['cid'],
620 626
                     'name' => $contest['name']
621 627
                 ];
622
-            }else{
628
+            } else{
623 629
                 $result[] = [
624 630
                     'ret' => 'judging',
625 631
                     'cid' => $contest['cid'],
Please login to merge, or discard this patch.
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
         foreach ($trending_groups as &$t) {
59 59
             $t["members"]=$this->countGroupMembers($t["gid"]);
60 60
         }
61
-        usort($trending_groups, function ($a, $b) {
61
+        usort($trending_groups, function($a, $b) {
62 62
             return $b["members"]<=>$a["members"];
63 63
         });
64
-        Cache::tags(['group'])->put('trending', array_slice($trending_groups,0,12), 3600*24);
64
+        Cache::tags(['group'])->put('trending', array_slice($trending_groups, 0, 12), 3600 * 24);
65 65
     }
66 66
 
67 67
     public function userGroups($uid)
@@ -101,13 +101,13 @@  discard block
 block discarded – undo
101 101
 
102 102
     public function changeGroupName($gid, $GroupName)
103 103
     {
104
-        return DB::table("group")->where('gid',$gid)->update([
104
+        return DB::table("group")->where('gid', $gid)->update([
105 105
             "name"=>$GroupName
106 106
         ]);
107 107
     }
108 108
 
109
-    public function changeJoinPolicy($gid, $JoinPolicy){
110
-        return DB::table("group")->where('gid',$gid)->update([
109
+    public function changeJoinPolicy($gid, $JoinPolicy) {
110
+        return DB::table("group")->where('gid', $gid)->update([
111 111
             "join_policy"=>$JoinPolicy
112 112
         ]);
113 113
     }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     public function details($gcode)
122 122
     {
123 123
         $basic_info=DB::table($this->tableName)->where(["gcode"=>$gcode])->first();
124
-        if(empty($basic_info)) return [];
124
+        if (empty($basic_info)) return [];
125 125
         $basic_info["members"]=$this->countGroupMembers($basic_info["gid"]);
126 126
         $basic_info["tags"]=$this->getGroupTags($basic_info["gid"]);
127 127
         $basic_info["create_time_foramt"]=date_format(date_create($basic_info["created_at"]), 'M jS, Y');
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
     public function userProfile($uid, $gid)
139 139
     {
140 140
         $info=DB::table("group_member")
141
-        ->join('users','users.id','=','group_member.uid')
141
+        ->join('users', 'users.id', '=', 'group_member.uid')
142 142
         ->where(["gid"=>$gid, "uid"=>$uid])
143 143
         ->where("role", ">", 0)
144
-        ->select('avatar','describes','email','gid','uid','name','nick_name','professional_rate','role','sub_group')
144
+        ->select('avatar', 'describes', 'email', 'gid', 'uid', 'name', 'nick_name', 'professional_rate', 'role', 'sub_group')
145 145
         ->first();
146 146
         if (!empty($info)) {
147 147
             $info["role_parsed"]=$this->role[$info["role"]];
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         foreach ($user_list as &$u) {
170 170
             $u["role_parsed"]=$this->role[$u["role"]];
171 171
             $u["role_color"]=$this->role_color[$u["role"]];
172
-            if(is_null($u["sub_group"])) $u["sub_group"]="None";
172
+            if (is_null($u["sub_group"])) $u["sub_group"]="None";
173 173
         }
174 174
         return $user_list;
175 175
     }
@@ -230,16 +230,16 @@  discard block
 block discarded – undo
230 230
         ])->where("role", ">", 0)->count();
231 231
     }
232 232
 
233
-    public function problemTags($gid,$pid = -1)
233
+    public function problemTags($gid, $pid=-1)
234 234
     {
235
-        if($pid == -1){
236
-            $tags =  DB::table('group_problem_tag')
235
+        if ($pid==-1) {
236
+            $tags=DB::table('group_problem_tag')
237 237
             ->select('tag')
238
-            ->where('gid',$gid)
238
+            ->where('gid', $gid)
239 239
             ->distinct()
240 240
             ->get()->all();
241
-        }else{
242
-            $tags =  DB::table('group_problem_tag')
241
+        } else {
242
+            $tags=DB::table('group_problem_tag')
243 243
             ->select('tag')
244 244
             ->where('gid', $gid)
245 245
             ->where('pid', $pid)
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
             ->get()->all();
248 248
         }
249 249
 
250
-        $tags_arr = [];
251
-        if(!empty($tags)){
250
+        $tags_arr=[];
251
+        if (!empty($tags)) {
252 252
             foreach ($tags as $value) {
253
-                array_push($tags_arr,$value['tag']);
253
+                array_push($tags_arr, $value['tag']);
254 254
             }
255 255
         }
256 256
         return $tags_arr;
@@ -258,28 +258,28 @@  discard block
 block discarded – undo
258 258
 
259 259
     public function problems($gid)
260 260
     {
261
-        $contestModel = new ContestModel();
262
-        $problems = DB::table('contest_problem')
263
-        ->join('contest','contest_problem.cid', '=', 'contest.cid')
264
-        ->join('problem','contest_problem.pid', '=', 'problem.pid' )
261
+        $contestModel=new ContestModel();
262
+        $problems=DB::table('contest_problem')
263
+        ->join('contest', 'contest_problem.cid', '=', 'contest.cid')
264
+        ->join('problem', 'contest_problem.pid', '=', 'problem.pid')
265 265
         ->select('contest_problem.cid as cid', 'problem.pid as pid', 'pcode', 'title')
266
-        ->where('contest.gid',$gid)
267
-        ->where('contest.practice',1)
268
-        ->orderBy('contest.created_at','desc')
266
+        ->where('contest.gid', $gid)
267
+        ->where('contest.practice', 1)
268
+        ->orderBy('contest.created_at', 'desc')
269 269
         ->distinct()
270 270
         ->get()->all();
271
-        $user_id = Auth::user()->id;
272
-        foreach($problems as $key => $value){
273
-            if($contestModel->judgeClearance($value['cid'],$user_id) != 3){
271
+        $user_id=Auth::user()->id;
272
+        foreach ($problems as $key => $value) {
273
+            if ($contestModel->judgeClearance($value['cid'], $user_id)!=3) {
274 274
                 unset($problems[$key]);
275
-            }else{
276
-                $problems[$key]['tags'] = $this->problemTags($gid,$value['pid']);
275
+            } else {
276
+                $problems[$key]['tags']=$this->problemTags($gid, $value['pid']);
277 277
             }
278 278
         }
279 279
         return $problems;
280 280
     }
281 281
 
282
-    public function problemAddTag($gid,$pid,$tag)
282
+    public function problemAddTag($gid, $pid, $tag)
283 283
     {
284 284
         return DB::table("group_problem_tag")->insert([
285 285
             "gid"=>$gid,
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
         ]);
289 289
     }
290 290
 
291
-    public function problemRemoveTag($gid,$pid,$tag)
291
+    public function problemRemoveTag($gid, $pid, $tag)
292 292
     {
293 293
         return DB::table("group_problem_tag")->where([
294 294
             "gid"=>$gid,
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
     public function judgeEmailClearance($gid, $email)
301 301
     {
302 302
         $user=DB::table("users")->where(["email"=>$email])->first();
303
-        if(empty($user)) return -4;
303
+        if (empty($user)) return -4;
304 304
         $ret=DB::table("group_member")->where([
305 305
             "gid"=>$gid,
306 306
             "uid"=>$user["id"],
@@ -391,20 +391,20 @@  discard block
 block discarded – undo
391 391
 
392 392
     public function groupMemberPracticeContestStat($gid)
393 393
     {
394
-        $contestModel = new ContestModel();
394
+        $contestModel=new ContestModel();
395 395
 
396
-        $allPracticeContest = DB::table('contest')
396
+        $allPracticeContest=DB::table('contest')
397 397
             ->where([
398 398
                 'gid' => $gid,
399 399
                 'practice' => 1,
400 400
             ])
401
-            ->select('cid','name')
401
+            ->select('cid', 'name')
402 402
             ->get()->all();
403
-        $user_list = $this->userList($gid);
403
+        $user_list=$this->userList($gid);
404 404
 
405
-        $memberData = [];
405
+        $memberData=[];
406 406
         foreach ($user_list as $u) {
407
-            $memberData[$u['uid']] = [
407
+            $memberData[$u['uid']]=[
408 408
                 'name' => $u['name'],
409 409
                 'nick_name' => $u['nick_name'],
410 410
                 'elo' => $u['ranking'],
@@ -415,61 +415,61 @@  discard block
 block discarded – undo
415 415
             ];
416 416
         }
417 417
         foreach ($allPracticeContest as $c) {
418
-            $contestRankRaw = $contestModel->contestRank($c['cid']);
419
-            foreach($contestRankRaw as $key => $contestRank){
420
-                if(isset($contestRank['remote']) && $contestRank['remote']){
418
+            $contestRankRaw=$contestModel->contestRank($c['cid']);
419
+            foreach ($contestRankRaw as $key => $contestRank) {
420
+                if (isset($contestRank['remote']) && $contestRank['remote']) {
421 421
                     unset($contestRankRaw[$key]);
422 422
                 }
423 423
             }
424
-            $contestRank = array_values($contestRankRaw);
425
-            $problemsCount = DB::table('contest_problem')
426
-                ->where('cid',$c['cid'])
424
+            $contestRank=array_values($contestRankRaw);
425
+            $problemsCount=DB::table('contest_problem')
426
+                ->where('cid', $c['cid'])
427 427
                 ->count();
428
-            $index = 1;
429
-            $rank = 1;
430
-            $last_cr = [];
431
-            $last_rank = 1;
428
+            $index=1;
429
+            $rank=1;
430
+            $last_cr=[];
431
+            $last_rank=1;
432 432
             foreach ($contestRank as $cr) {
433
-                $last_rank = $index;
434
-                if(!empty($last_cr)){
435
-                    if($cr['solved'] == $last_cr['solved'] && $cr['penalty'] == $last_cr['penalty'] ){
436
-                        $rank = $last_rank;
437
-                    }else{
438
-                        $rank = $index;
439
-                        $last_rank = $rank;
433
+                $last_rank=$index;
434
+                if (!empty($last_cr)) {
435
+                    if ($cr['solved']==$last_cr['solved'] && $cr['penalty']==$last_cr['penalty']) {
436
+                        $rank=$last_rank;
437
+                    } else {
438
+                        $rank=$index;
439
+                        $last_rank=$rank;
440 440
                     }
441 441
                 }
442
-                if(in_array($cr['uid'],array_keys($memberData))) {
443
-                    $memberData[$cr['uid']]['solved_all'] += $cr['solved'];
444
-                    $memberData[$cr['uid']]['problem_all'] += $problemsCount;
445
-                    $memberData[$cr['uid']]['penalty'] += $cr['penalty'];
446
-                    $memberData[$cr['uid']]['contest_detial'][$c['cid']] = [
442
+                if (in_array($cr['uid'], array_keys($memberData))) {
443
+                    $memberData[$cr['uid']]['solved_all']+=$cr['solved'];
444
+                    $memberData[$cr['uid']]['problem_all']+=$problemsCount;
445
+                    $memberData[$cr['uid']]['penalty']+=$cr['penalty'];
446
+                    $memberData[$cr['uid']]['contest_detial'][$c['cid']]=[
447 447
                         'rank' => $rank,
448 448
                         'solved' => $cr['solved'],
449 449
                         'problems' => $problemsCount,
450 450
                         'penalty' => $cr['penalty']
451 451
                     ];
452 452
                 }
453
-                $last_cr = $cr;
453
+                $last_cr=$cr;
454 454
                 $index++;
455 455
             }
456 456
         }
457
-        $new_memberData = [];
457
+        $new_memberData=[];
458 458
         foreach ($memberData as $uid => $data) {
459
-            $contest_count = 0;
460
-            $rank_sum = 0;
459
+            $contest_count=0;
460
+            $rank_sum=0;
461 461
             foreach ($data['contest_detial'] as $cid => $c) {
462
-                $rank_sum += $c['rank'];
463
-                $contest_count += 1;
462
+                $rank_sum+=$c['rank'];
463
+                $contest_count+=1;
464 464
             }
465
-            $temp = $data;
466
-            $temp['uid'] = $uid;
467
-            if($contest_count != 0){
468
-                $temp['rank_ave'] = $rank_sum/$contest_count;
465
+            $temp=$data;
466
+            $temp['uid']=$uid;
467
+            if ($contest_count!=0) {
468
+                $temp['rank_ave']=$rank_sum / $contest_count;
469 469
             }
470
-            array_push($new_memberData,$temp);
470
+            array_push($new_memberData, $temp);
471 471
         }
472
-        $ret = [
472
+        $ret=[
473 473
             'contest_list' => $allPracticeContest,
474 474
             'member_data' => $new_memberData
475 475
         ];
@@ -478,58 +478,58 @@  discard block
 block discarded – undo
478 478
 
479 479
     public function groupMemberPracticeTagStat($gid)
480 480
     {
481
-        $tags = $this->problemTags($gid);
482
-        $tag_problems = [];
481
+        $tags=$this->problemTags($gid);
482
+        $tag_problems=[];
483 483
 
484
-        $user_list = $this->userList($gid);
484
+        $user_list=$this->userList($gid);
485 485
         foreach ($tags as $tag) {
486
-            $tag_problems[$tag] = DB::table('problem')
487
-                ->join('group_problem_tag','problem.pid','=','group_problem_tag.pid')
486
+            $tag_problems[$tag]=DB::table('problem')
487
+                ->join('group_problem_tag', 'problem.pid', '=', 'group_problem_tag.pid')
488 488
                 ->where([
489 489
                     'group_problem_tag.gid' => $gid,
490 490
                     'tag' => $tag
491 491
                 ])
492
-                ->select('group_problem_tag.pid as pid','pcode','title')
492
+                ->select('group_problem_tag.pid as pid', 'pcode', 'title')
493 493
                 ->get()->all();
494 494
         }
495
-        $all_problems = [];
495
+        $all_problems=[];
496 496
         foreach ($tag_problems as &$tag_problem_set) {
497 497
             foreach ($tag_problem_set as $problem) {
498
-                $all_problems[$problem['pid']] = $problem;
498
+                $all_problems[$problem['pid']]=$problem;
499 499
             }
500
-            $tag_problem_set = array_column($tag_problem_set,'pid');
500
+            $tag_problem_set=array_column($tag_problem_set, 'pid');
501 501
         }
502
-        $submission_data =  DB::table('submission')
503
-            ->whereIn('pid',array_keys($all_problems))
504
-            ->whereIn('uid',array_column($user_list,'uid'))
505
-            ->where('verdict','Accepted')
506
-            ->select('pid','uid')
502
+        $submission_data=DB::table('submission')
503
+            ->whereIn('pid', array_keys($all_problems))
504
+            ->whereIn('uid', array_column($user_list, 'uid'))
505
+            ->where('verdict', 'Accepted')
506
+            ->select('pid', 'uid')
507 507
             ->get()->all();
508 508
 
509
-        $memberData = [];
509
+        $memberData=[];
510 510
         foreach ($user_list as $member) {
511
-            $completion = [];
512
-            foreach($tag_problems as $tag => $problems) {
513
-                $completion[$tag] = [];
511
+            $completion=[];
512
+            foreach ($tag_problems as $tag => $problems) {
513
+                $completion[$tag]=[];
514 514
                 foreach ($problems as $problem) {
515
-                    $is_accepted = 0;
515
+                    $is_accepted=0;
516 516
                     foreach ($submission_data as $sd) {
517
-                        if($sd['pid'] == $problem && $sd['uid'] == $member['uid']){
518
-                            $is_accepted = 1;
517
+                        if ($sd['pid']==$problem && $sd['uid']==$member['uid']) {
518
+                            $is_accepted=1;
519 519
                             break;
520 520
                         }
521 521
                     }
522
-                    $completion[$tag][$problem] = $is_accepted;
522
+                    $completion[$tag][$problem]=$is_accepted;
523 523
                 }
524 524
             }
525
-            array_push($memberData,[
525
+            array_push($memberData, [
526 526
                 'uid' => $member['uid'],
527 527
                 'name' => $member['name'],
528 528
                 'nick_name' => $member['nick_name'],
529 529
                 'completion' => $completion,
530 530
             ]);
531 531
         }
532
-        $ret = [
532
+        $ret=[
533 533
             'all_problems' => $all_problems,
534 534
             'tag_problems' => $tag_problems,
535 535
             'member_data' => $memberData
@@ -539,10 +539,10 @@  discard block
 block discarded – undo
539 539
 
540 540
     public function refreshAllElo()
541 541
     {
542
-        $result = [];
543
-        $gids = DB::table('group')->select('gid','name')->get()->all();
542
+        $result=[];
543
+        $gids=DB::table('group')->select('gid', 'name')->get()->all();
544 544
         foreach ($gids as $gid) {
545
-            $result[$gid['gid']] = [
545
+            $result[$gid['gid']]=[
546 546
                 'name' => $gid['name'],
547 547
                 'result' => $this->refreshElo($gid['gid']),
548 548
             ];
@@ -553,41 +553,41 @@  discard block
 block discarded – undo
553 553
     public function refreshElo($gid)
554 554
     {
555 555
         DB::table('group_rated_change_log')
556
-            ->where('gid',$gid)
556
+            ->where('gid', $gid)
557 557
             ->delete();
558 558
         DB::table('group_member')
559
-            ->where('gid',$gid)
559
+            ->where('gid', $gid)
560 560
             ->update([
561 561
                 'ranking' => 1500
562 562
             ]);
563
-        $contests = DB::table('contest')
563
+        $contests=DB::table('contest')
564 564
             ->where([
565 565
                 'gid' => $gid,
566 566
                 'practice' => 1
567 567
             ])
568
-            ->where('end_time','<',date("Y-m-d H:i:s"))
569
-            ->select('cid','name')
568
+            ->where('end_time', '<', date("Y-m-d H:i:s"))
569
+            ->select('cid', 'name')
570 570
             ->orderBy('end_time')
571 571
             ->get()->all();
572 572
 
573
-        if(empty($contests)) {
573
+        if (empty($contests)) {
574 574
             return [];
575 575
         }
576
-        $result = [];
577
-        $contestModel = new ContestModel();
576
+        $result=[];
577
+        $contestModel=new ContestModel();
578 578
         foreach ($contests as $contest) {
579
-            $judge_status = $contestModel->judgeOver($contest['cid']);
580
-            if($judge_status['result'] == true){
581
-                $calc = new GroupRatingCalculator($contest['cid']);
579
+            $judge_status=$contestModel->judgeOver($contest['cid']);
580
+            if ($judge_status['result']==true) {
581
+                $calc=new GroupRatingCalculator($contest['cid']);
582 582
                 $calc->calculate();
583 583
                 $calc->storage();
584
-                $result[] = [
584
+                $result[]=[
585 585
                     'ret' => 'success',
586 586
                     'cid' => $contest['cid'],
587 587
                     'name' => $contest['name']
588 588
                 ];
589
-            }else{
590
-                $result[] = [
589
+            } else {
590
+                $result[]=[
591 591
                     'ret' => 'judging',
592 592
                     'cid' => $contest['cid'],
593 593
                     'name' => $contest['name'],
@@ -599,21 +599,21 @@  discard block
 block discarded – undo
599 599
         return $result;
600 600
     }
601 601
 
602
-    public function getEloChangeLog($gid,$uid)
602
+    public function getEloChangeLog($gid, $uid)
603 603
     {
604
-        $ret = DB::table('group_rated_change_log')
605
-            ->join('contest','group_rated_change_log.cid','=','contest.cid')
604
+        $ret=DB::table('group_rated_change_log')
605
+            ->join('contest', 'group_rated_change_log.cid', '=', 'contest.cid')
606 606
             ->where([
607 607
                 'group_rated_change_log.gid' => $gid,
608 608
                 'group_rated_change_log.uid' => $uid
609 609
             ])->select('group_rated_change_log.cid as cid', 'contest.name as name', 'ranking', 'end_time')
610 610
             ->orderBy('contest.end_time')
611 611
             ->get()->all();
612
-        $begin = [
612
+        $begin=[
613 613
             'cid' => -1,
614 614
             'name' => '',
615 615
             'ranking' => '1500',
616
-            'end_time' => date("Y-m-d H:i:s",(strtotime($ret[0]['end_time'] ?? time())  - 3600*24)),
616
+            'end_time' => date("Y-m-d H:i:s", (strtotime($ret[0]['end_time'] ?? time())-3600 * 24)),
617 617
         ];
618 618
         array_unshift($ret, $begin);
619 619
         return $ret;
Please login to merge, or discard this patch.
app/Models/Eloquent/Message.php 2 patches
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -17,78 +17,78 @@  discard block
 block discarded – undo
17 17
      */
18 18
     public static function send($config)
19 19
     {
20
-        if(!empty($config['type'])){
21
-            if($config['type'] == 1) { //to a leader that member apply to join the group
22
-                $messages = Message::where([
20
+        if (!empty($config['type'])) {
21
+            if ($config['type']==1) { //to a leader that member apply to join the group
22
+                $messages=Message::where([
23 23
                     'receiver' => $config['receiver'],
24 24
                     'type'     => $config['type'],
25 25
                     'unread'   => 1
26 26
                 ])->get();
27
-                if(!empty($messages)) {
28
-                    foreach($messages as $message) {
29
-                        $data = json_decode($message->data,true);
30
-                        if($data['group']['gcode'] == $config['data']['group']['gcode']) {
31
-                            array_push($data['user'],$config['data']['user'][0]);
32
-                            $message->data = json_encode($data);
27
+                if (!empty($messages)) {
28
+                    foreach ($messages as $message) {
29
+                        $data=json_decode($message->data, true);
30
+                        if ($data['group']['gcode']==$config['data']['group']['gcode']) {
31
+                            array_push($data['user'], $config['data']['user'][0]);
32
+                            $message->data=json_encode($data);
33 33
                             $message->save();
34 34
                             return true;
35 35
                         }
36 36
                     }
37 37
                 }
38
-            }elseif ($config['type'] == 2) { //to a leader that member agree to join the group
39
-                $messages = Message::where([
38
+            }elseif ($config['type']==2) { //to a leader that member agree to join the group
39
+                $messages=Message::where([
40 40
                     'receiver' => $config['receiver'],
41 41
                     'type'     => $config['type'],
42 42
                     'unread'   => 1
43 43
                 ])->get();
44
-                if(!empty($messages)) {
45
-                    foreach($messages as $message) {
46
-                        $data = json_decode($message->data,true);
47
-                        if($data['group'] == $config['data']['group']) {
48
-                            array_push($data['user'],$config['data']['user'][0]);
49
-                            $message->data = json_encode($data);
44
+                if (!empty($messages)) {
45
+                    foreach ($messages as $message) {
46
+                        $data=json_decode($message->data, true);
47
+                        if ($data['group']==$config['data']['group']) {
48
+                            array_push($data['user'], $config['data']['user'][0]);
49
+                            $message->data=json_encode($data);
50 50
                             $message->save();
51 51
                             return true;
52 52
                         }
53 53
                     }
54 54
                 }
55
-            }elseif ($config['type'] == 3) { //to a person that solution was passed
56
-                $message = Message::where([
55
+            }elseif ($config['type']==3) { //to a person that solution was passed
56
+                $message=Message::where([
57 57
                     'receiver' => $config['receiver'],
58 58
                     'type'     => $config['type'],
59 59
                     'unread'   => 1
60 60
                 ])->first();
61
-                if(!empty($message)) {
62
-                    $data = json_decode($message->data,true);
63
-                    array_push($data,$config['data']);
64
-                    $message->data = json_encode($data);
61
+                if (!empty($message)) {
62
+                    $data=json_decode($message->data, true);
63
+                    array_push($data, $config['data']);
64
+                    $message->data=json_encode($data);
65 65
                     $message->save();
66 66
                     return true;
67 67
                 }
68
-            }elseif ($config['type'] == 4) { //to a person that solution was blocked
69
-                $message = Message::where([
68
+            }elseif ($config['type']==4) { //to a person that solution was blocked
69
+                $message=Message::where([
70 70
                     'receiver' => $config['receiver'],
71 71
                     'type'     => $config['type'],
72 72
                     'unread'   => 1
73 73
                 ])->first();
74
-                if(!empty($message)) {
75
-                    $data = json_decode($message->data,true);
76
-                    array_push($data,$config['data']);
77
-                    $message->data = json_encode($data);
74
+                if (!empty($message)) {
75
+                    $data=json_decode($message->data, true);
76
+                    array_push($data, $config['data']);
77
+                    $message->data=json_encode($data);
78 78
                     $message->save();
79 79
                     return true;
80 80
                 }
81 81
             }
82 82
         }
83
-        $message = new Message;
84
-        $message->sender = $config['sender'];
85
-        $message->receiver = $config['receiver'];
86
-        $message->title = $config['title'];
87
-        if(isset($config['data']) && isset($config['type'])){
88
-            $message->type = $config['type'] ?? null;
89
-            $message->data = json_encode($config['data']);
90
-        }else{
91
-            $message->content = $config['content'];
83
+        $message=new Message;
84
+        $message->sender=$config['sender'];
85
+        $message->receiver=$config['receiver'];
86
+        $message->title=$config['title'];
87
+        if (isset($config['data']) && isset($config['type'])) {
88
+            $message->type=$config['type'] ?? null;
89
+            $message->data=json_encode($config['data']);
90
+        } else {
91
+            $message->content=$config['content'];
92 92
         }
93 93
         /*
94 94
         if(isset($config['reply'])){
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             $message->reply = $config['allow_reply'];
99 99
         }
100 100
         */
101
-        $message->official = 1;
101
+        $message->official=1;
102 102
         $message->save();
103 103
         return true;
104 104
     }
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
     {
133 133
 
134 134
         return static::with('sender_user')
135
-            ->where('receiver',$uid)
136
-            ->orderBy('unread','desc')
137
-            ->orderBy('updated_at','desc')
135
+            ->where('receiver', $uid)
136
+            ->orderBy('unread', 'desc')
137
+            ->orderBy('updated_at', 'desc')
138 138
             ->paginate(15);
139 139
     }
140 140
 
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
      */
148 148
     public static function read($mid)
149 149
     {
150
-        $message = static::with('sender_user')->find($mid);
151
-        if(!empty($message)){
152
-            $message->unread = 0;
150
+        $message=static::with('sender_user')->find($mid);
151
+        if (!empty($message)) {
152
+            $message->unread=0;
153 153
             $message->save();
154 154
         }
155 155
         return $message;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public static function allRead($uid)
166 166
     {
167
-        return static::where('receiver',$uid)
167
+        return static::where('receiver', $uid)
168 168
             ->update(['unread' => 0]);
169 169
     }
170 170
 
@@ -192,20 +192,20 @@  discard block
 block discarded – undo
192 192
      */
193 193
     public static function remove($messages)
194 194
     {
195
-        $del_count = 0;
196
-        if(is_array($messages)){
195
+        $del_count=0;
196
+        if (is_array($messages)) {
197 197
             foreach ($messages as $mid) {
198
-                $message = static::find($mid);
199
-                if(!empty($message)){
198
+                $message=static::find($mid);
199
+                if (!empty($message)) {
200 200
                     $message->delete();
201
-                    $del_count ++;
201
+                    $del_count++;
202 202
                 }
203 203
             }
204
-        }else{
205
-            $message = static::find($messages);
206
-            if(!empty($message)){
204
+        } else {
205
+            $message=static::find($messages);
206
+            if (!empty($message)) {
207 207
                 $message->delete();
208
-                $del_count ++;
208
+                $del_count++;
209 209
             }
210 210
         }
211 211
         return $del_count;
@@ -213,36 +213,36 @@  discard block
 block discarded – undo
213 213
 
214 214
     public function getContentAttribute($value)
215 215
     {
216
-        if(!empty($this->type)){
217
-            $data = json_decode($this->data,true);
218
-            $content = '';
219
-            if($this->type == 1) {
220
-                foreach($data['user'] as $user) {
221
-                    $content .= "[{$user['name']}]({$user['url']}), ";
216
+        if (!empty($this->type)) {
217
+            $data=json_decode($this->data, true);
218
+            $content='';
219
+            if ($this->type==1) {
220
+                foreach ($data['user'] as $user) {
221
+                    $content.="[{$user['name']}]({$user['url']}), ";
222 222
                 }
223
-                $content = substr($content,0,strlen($content)-2);
224
-                $content .= " want to join your group [{$data['group']['name']}]({$data['group']['url']})";
223
+                $content=substr($content, 0, strlen($content)-2);
224
+                $content.=" want to join your group [{$data['group']['name']}]({$data['group']['url']})";
225 225
                 return $content;
226
-            }elseif($this->type == 2) {
227
-                foreach($data['user'] as $user) {
228
-                    $content .= "[{$user['name']}]({$user['url']}), ";
226
+            }elseif ($this->type==2) {
227
+                foreach ($data['user'] as $user) {
228
+                    $content.="[{$user['name']}]({$user['url']}), ";
229 229
                 }
230
-                $content = substr($content,0,strlen($content)-2);
231
-                $content .= " have agreed to join your group [{$data['group']['name']}]({$data['group']['url']})";
230
+                $content=substr($content, 0, strlen($content)-2);
231
+                $content.=" have agreed to join your group [{$data['group']['name']}]({$data['group']['url']})";
232 232
                 return $content;
233 233
             } //todo
234
-        }else{
234
+        } else {
235 235
             return $value;
236 236
         }
237 237
     }
238 238
 
239 239
     public function sender_user()
240 240
     {
241
-        return $this->belongsTo('App\Models\Eloquent\UserModel','sender','id');
241
+        return $this->belongsTo('App\Models\Eloquent\UserModel', 'sender', 'id');
242 242
     }
243 243
 
244 244
     public function receiver_user()
245 245
     {
246
-        return $this->belongsTo('App\Models\Eloquent\UserModel','receiver','id');
246
+        return $this->belongsTo('App\Models\Eloquent\UserModel', 'receiver', 'id');
247 247
     }
248 248
 }
Please login to merge, or discard this patch.
Braces   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
                         }
36 36
                     }
37 37
                 }
38
-            }elseif ($config['type'] == 2) { //to a leader that member agree to join the group
38
+            } elseif ($config['type'] == 2) { //to a leader that member agree to join the group
39 39
                 $messages = Message::where([
40 40
                     'receiver' => $config['receiver'],
41 41
                     'type'     => $config['type'],
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
                         }
53 53
                     }
54 54
                 }
55
-            }elseif ($config['type'] == 3) { //to a person that solution was passed
55
+            } elseif ($config['type'] == 3) { //to a person that solution was passed
56 56
                 $message = Message::where([
57 57
                     'receiver' => $config['receiver'],
58 58
                     'type'     => $config['type'],
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
                     $message->save();
66 66
                     return true;
67 67
                 }
68
-            }elseif ($config['type'] == 4) { //to a person that solution was blocked
68
+            } elseif ($config['type'] == 4) { //to a person that solution was blocked
69 69
                 $message = Message::where([
70 70
                     'receiver' => $config['receiver'],
71 71
                     'type'     => $config['type'],
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         if(isset($config['data']) && isset($config['type'])){
88 88
             $message->type = $config['type'] ?? null;
89 89
             $message->data = json_encode($config['data']);
90
-        }else{
90
+        } else{
91 91
             $message->content = $config['content'];
92 92
         }
93 93
         /*
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
                     $del_count ++;
202 202
                 }
203 203
             }
204
-        }else{
204
+        } else{
205 205
             $message = static::find($messages);
206 206
             if(!empty($message)){
207 207
                 $message->delete();
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
                 $content = substr($content,0,strlen($content)-2);
224 224
                 $content .= " want to join your group [{$data['group']['name']}]({$data['group']['url']})";
225 225
                 return $content;
226
-            }elseif($this->type == 2) {
226
+            } elseif($this->type == 2) {
227 227
                 foreach($data['user'] as $user) {
228 228
                     $content .= "[{$user['name']}]({$user['url']}), ";
229 229
                 }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
                 $content .= " have agreed to join your group [{$data['group']['name']}]({$data['group']['url']})";
232 232
                 return $content;
233 233
             } //todo
234
-        }else{
234
+        } else{
235 235
             return $value;
236 236
         }
237 237
     }
Please login to merge, or discard this patch.
app/Models/Eloquent/GroupMember.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@
 block discarded – undo
13 13
     protected $primaryKey='gmid';
14 14
 
15 15
     public function user() {
16
-        return $this->belongsTo('App\Models\Eloquent\UserModel','uid','id');
16
+        return $this->belongsTo('App\Models\Eloquent\UserModel', 'uid', 'id');
17 17
     }
18 18
 
19 19
     public function group() {
20
-        return $this->belongsTo('App\Models\Eloquent\Group','gid','gid');
20
+        return $this->belongsTo('App\Models\Eloquent\Group', 'gid', 'gid');
21 21
     }
22 22
 }
Please login to merge, or discard this patch.