Passed
Pull Request — master (#610)
by John
10:48
created
app/Models/Eloquent/UserPermission.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@
 block discarded – undo
6 6
 
7 7
 class UserPermission extends Model
8 8
 {
9
-    protected $fillable = [
9
+    protected $fillable=[
10 10
         'user_id', 'permission_id'
11 11
     ];
12 12
 
13
-    public static $permInfo = [
13
+    public static $permInfo=[
14 14
         '1' => 'Show site admin badge and allow frontend access to admin portal',
15 15
         // Why 26 you may ask? Praise be the all-mighty samsung AC that keeps my room at 26 celsius.
16 16
         '26' => 'Allow access to image hosting services',
Please login to merge, or discard this patch.
app/Models/Eloquent/Group.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
     public function members()
12 12
     {
13
-        return $this->hasMany('App\Models\Eloquent\GroupMember', 'gid','gid');
13
+        return $this->hasMany('App\Models\Eloquent\GroupMember', 'gid', 'gid');
14 14
     }
15 15
 
16 16
     public function banneds()
@@ -21,20 +21,20 @@  discard block
 block discarded – undo
21 21
     public static function boot()
22 22
     {
23 23
         parent::boot();
24
-        static::saving(function ($model) {
25
-            if( $model->img != "" && $model->img != null && $model->img[0] != "/" ) {
26
-                $model->img =  "/$model->img";
24
+        static::saving(function($model) {
25
+            if ($model->img!="" && $model->img!=null && $model->img[0]!="/") {
26
+                $model->img="/$model->img";
27 27
             }
28 28
         });
29 29
     }
30 30
 
31 31
     public function getLeaderAttribute()
32 32
     {
33
-        return $this->members()->where('role',3)->first()->user;
33
+        return $this->members()->where('role', 3)->first()->user;
34 34
     }
35 35
 
36 36
     public function getLinkAttribute()
37 37
     {
38
-        return route('group.detail',['gcode' => $this->gcode]);
38
+        return route('group.detail', ['gcode' => $this->gcode]);
39 39
     }
40 40
 }
Please login to merge, or discard this patch.
app/Models/Eloquent/Submission.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     const UPDATED_AT=null;
14 14
     const CREATED_AT=null;
15 15
 
16
-    protected $guarded = [];
16
+    protected $guarded=[];
17 17
 
18 18
     public function compiler()
19 19
     {
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function getJudgerNameAttribute()
44 44
     {
45
-        if(!is_null($this->judger)){
45
+        if (!is_null($this->judger)) {
46 46
             return $this->judger->readable_name;
47 47
         }
48 48
         return '-';
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 
51 51
     public function getNcodeAttribute()
52 52
     {
53
-        $contest = $this->contest;
53
+        $contest=$this->contest;
54 54
         return $contest->problems->where('pid', $this->pid)->first()->ncode;
55 55
     }
56 56
 
57 57
     public function getNickNameAttribute()
58 58
     {
59
-        $member = $this->contest->group->members()->where('uid', $this->user->id)->first();
60
-        if(!empty($member)) {
59
+        $member=$this->contest->group->members()->where('uid', $this->user->id)->first();
60
+        if (!empty($member)) {
61 61
             return $member->nickname;
62 62
         }
63 63
         return null;
@@ -94,17 +94,17 @@  discard block
 block discarded – undo
94 94
 
95 95
     public function getParsedScoreAttribute()
96 96
     {
97
-        if(is_null($this->contest)) {
97
+        if (is_null($this->contest)) {
98 98
             $tot_score=100;
99 99
         } else {
100 100
             $tot_score=$this->contest->problems->where('pid', $this->pid)->first()->points;
101 101
         }
102
-        return round($this->score/max($this->problem->tot_score,1)*$tot_score,1);
102
+        return round($this->score / max($this->problem->tot_score, 1) * $tot_score, 1);
103 103
     }
104 104
 
105 105
     public function getSubmissionDateParsedAttribute()
106 106
     {
107
-        $submission_date = date('Y-m-d H:i:s', $this->submission_date);
107
+        $submission_date=date('Y-m-d H:i:s', $this->submission_date);
108 108
         return formatHumanReadableTime($submission_date);
109 109
     }
110 110
 
Please login to merge, or discard this patch.
app/Models/Eloquent/JudgeServer.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,17 +20,17 @@
 block discarded – undo
20 20
     }
21 21
 
22 22
     public function oj() {
23
-        return $this->belongsTo('App\Models\Eloquent\OJ','oid','oid');
23
+        return $this->belongsTo('App\Models\Eloquent\OJ', 'oid', 'oid');
24 24
     }
25 25
 
26 26
     public static function boot()
27 27
     {
28 28
         parent::boot();
29
-        static::saving(function ($model) {
30
-            $columns = $model->getDirty();
29
+        static::saving(function($model) {
30
+            $columns=$model->getDirty();
31 31
             foreach ($columns as $column => $newValue) {
32
-                if( $column == "status" ) {
33
-                    $model->status_update_at = now();
32
+                if ($column=="status") {
33
+                    $model->status_update_at=now();
34 34
                     break;
35 35
                 }
36 36
             }
Please login to merge, or discard this patch.
app/Models/Eloquent/GroupBanned.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@
 block discarded – undo
9 9
 {
10 10
     use SoftDeletes;
11 11
 
12
-    protected $fillable = ['group_id', 'abuse_id', 'reason', 'removed_at'];
12
+    protected $fillable=['group_id', 'abuse_id', 'reason', 'removed_at'];
13 13
 
14 14
     public function abuse() {
15 15
         return $this->belongsTo('App\Models\Eloquent\Abuse');
16 16
     }
17 17
 
18 18
     public function group() {
19
-        return $this->belongsTo('App\Models\Eloquent\Group',null,'gid');
19
+        return $this->belongsTo('App\Models\Eloquent\Group', null, 'gid');
20 20
     }
21 21
 }
Please login to merge, or discard this patch.
app/Models/Eloquent/ContestProblem.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -9,37 +9,37 @@  discard block
 block discarded – undo
9 9
 {
10 10
     protected $table='contest_problem';
11 11
     protected $primaryKey='cpid';
12
-    public $timestamps = null;
12
+    public $timestamps=null;
13 13
 
14
-    protected $fillable = [
14
+    protected $fillable=[
15 15
         'number', 'ncode', 'pid', 'alias', 'points'
16 16
     ];
17 17
 
18 18
     public function contest()
19 19
     {
20
-        return $this->belongsTo('App\Models\Eloquent\Contest','cid','cid');
20
+        return $this->belongsTo('App\Models\Eloquent\Contest', 'cid', 'cid');
21 21
     }
22 22
 
23 23
     public function problem()
24 24
     {
25
-        return $this->belongsTo('App\Models\Eloquent\Problem','pid','pid');
25
+        return $this->belongsTo('App\Models\Eloquent\Problem', 'pid', 'pid');
26 26
     }
27 27
 
28 28
     public function submissions()
29 29
     {
30
-        return $this->problem->submissions()->where('cid',$this->contest->cid);
30
+        return $this->problem->submissions()->where('cid', $this->contest->cid);
31 31
     }
32 32
 
33 33
     public function getCompilersAttribute()
34 34
     {
35
-        $special = $this->problem->special_compiler;
36
-        $compilers = Compiler::where([
35
+        $special=$this->problem->special_compiler;
36
+        $compilers=Compiler::where([
37 37
             'oid' => $this->problem->OJ,
38 38
             'available' => 1,
39 39
             'deleted' => 0
40 40
         ]);
41
-        if(!empty($special)) {
42
-            $compilers = $compilers->whereIn('coid', explode(',', $special));
41
+        if (!empty($special)) {
42
+            $compilers=$compilers->whereIn('coid', explode(',', $special));
43 43
         }
44 44
         return $compilers;
45 45
     }
@@ -54,15 +54,15 @@  discard block
 block discarded – undo
54 54
             'wrong_doings'       => 0,
55 55
             'color'              => '',
56 56
         ];
57
-        $ac_record = $this->ac_record($user);
58
-        if(!empty($ac_record[0])){
59
-            $ret['solved']             = 1;
60
-            $ret['solved_time']        = $ac_record[0]->submission_date - strtotime($this->contest->begin_time);
61
-            $ret['solved_time_parsed'] = formatProblemSolvedTime($ret['solved_time']);
62
-            $ret['wrong_doings']       = $ac_record[2];
63
-            $ret['color']              = $ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text';
64
-        }else{
65
-            $ret['wrong_doings']       = $ac_record[2];
57
+        $ac_record=$this->ac_record($user);
58
+        if (!empty($ac_record[0])) {
59
+            $ret['solved']=1;
60
+            $ret['solved_time']=$ac_record[0]->submission_date-strtotime($this->contest->begin_time);
61
+            $ret['solved_time_parsed']=formatProblemSolvedTime($ret['solved_time']);
62
+            $ret['wrong_doings']=$ac_record[2];
63
+            $ret['color']=$ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text';
64
+        } else {
65
+            $ret['wrong_doings']=$ac_record[2];
66 66
         }
67 67
         return $ret;
68 68
     }
@@ -70,19 +70,19 @@  discard block
 block discarded – undo
70 70
     public function ac_record($user)
71 71
     {
72 72
         $frozen_time=$this->contest->frozen_time;
73
-        $user_ac = $this->submissions()->where([
73
+        $user_ac=$this->submissions()->where([
74 74
             'uid'     => $user->id,
75 75
             'verdict' => 'Accepted'
76 76
         ])->where("submission_date", "<", $frozen_time)->orderBy('submission_date', 'asc')->first();
77 77
 
78
-        $other_ac = 1;
79
-        $wrong_trys = 0;
80
-        if(!empty($user_ac)){
81
-            $other_ac = $this->submissions()
82
-                ->where('verdict','Accepted')
78
+        $other_ac=1;
79
+        $wrong_trys=0;
80
+        if (!empty($user_ac)) {
81
+            $other_ac=$this->submissions()
82
+                ->where('verdict', 'Accepted')
83 83
                 ->where('submission_date', '<', $user_ac->submission_date)
84 84
                 ->count();
85
-            $wrong_trys = $this->submissions()->where([
85
+            $wrong_trys=$this->submissions()->where([
86 86
                     'uid'     => $user->id,
87 87
                 ])->whereIn('verdict', [
88 88
                     'Runtime Error',
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
                     'Presentation Error',
94 94
                     'Output Limit Exceeded'
95 95
                 ])->where('submission_date', '<', $user_ac->submission_date)->count();
96
-        }else{
97
-            $wrong_trys = $this->submissions()->where([
96
+        } else {
97
+            $wrong_trys=$this->submissions()->where([
98 98
                 'uid'     => $user->id,
99 99
             ])->whereIn('verdict', [
100 100
                 'Runtime Error',
Please login to merge, or discard this patch.
app/Models/Eloquent/UserExtra.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@  discard block
 block discarded – undo
9 9
 {
10 10
     protected $table='users_extra';
11 11
 
12
-    protected $fillable = ['uid', 'key', 'value', 'secret_level'];
12
+    protected $fillable=['uid', 'key', 'value', 'secret_level'];
13 13
 
14
-    public static $extraMapping = [
14
+    public static $extraMapping=[
15 15
         0     => 'gender',
16 16
         1     => 'contact',
17 17
         2     => 'school',
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         1011  => 'aauth_nickname',
30 30
     ];
31 31
 
32
-    public static $extraDict = [
32
+    public static $extraDict=[
33 33
         'gender' => [
34 34
             'icon' => 'MDI gender-transgender',
35 35
             'locale' => 'dashboard.setting.gender',
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
         ],
53 53
     ];
54 54
 
55
-    public static $socialite_support = [
55
+    public static $socialite_support=[
56 56
         //use the form "platform_id" for unique authentication
57 57
         //such as github_id
58 58
         'github' => [
59
-            'email','nickname','homepage','token'
59
+            'email', 'nickname', 'homepage', 'token'
60 60
         ],
61 61
         'aauth' => [
62 62
             'nickname'
@@ -75,13 +75,13 @@  discard block
 block discarded – undo
75 75
      */
76 76
     public static function search($key, $value)
77 77
     {
78
-        $key = array_search($key, UserExtra::$extraMapping);
79
-        if($key){
78
+        $key=array_search($key, UserExtra::$extraMapping);
79
+        if ($key) {
80 80
             return self::where([
81 81
                 'key' => $key,
82 82
                 'value' => $value
83 83
             ])->limit(1)->get()->toArray();
84
-        }else{
84
+        } else {
85 85
             return null;
86 86
         }
87 87
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@
 block discarded – undo
81 81
                 'key' => $key,
82 82
                 'value' => $value
83 83
             ])->limit(1)->get()->toArray();
84
-        }else{
84
+        } else{
85 85
             return null;
86 86
         }
87 87
     }
Please login to merge, or discard this patch.
app/Models/Eloquent/Judger.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,6 +25,6 @@
 block discarded – undo
25 25
     }
26 26
 
27 27
     public function oj() {
28
-        return $this->belongsTo('App\Models\Eloquent\OJ','oid','oid');
28
+        return $this->belongsTo('App\Models\Eloquent\OJ', 'oid', 'oid');
29 29
     }
30 30
 }
Please login to merge, or discard this patch.
app/Models/Eloquent/User.php 2 patches
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -53,19 +53,19 @@  discard block
 block discarded – undo
53 53
         return $this->hasMany('App\Models\Eloquent\UserExtra', 'uid');
54 54
     }
55 55
 
56
-    public function hasPermission($permissionID){
56
+    public function hasPermission($permissionID) {
57 57
         return ($this->permissions()->where(['permission_id'=>$permissionID])->count())>0;
58 58
     }
59 59
 
60
-    public function hasIndependentPassword(){
60
+    public function hasIndependentPassword() {
61 61
         return filled($this->password);
62 62
     }
63 63
 
64
-    public function hasIndependentEmail(){
64
+    public function hasIndependentEmail() {
65 65
         return !in_array(explode('@', $this->email)[1], ['temporary.email']) && !$this->contest_account;
66 66
     }
67 67
 
68
-    public function isIndependent(){
68
+    public function isIndependent() {
69 69
         return $this->hasIndependentPassword() && $this->hasIndependentEmail();
70 70
     }
71 71
 
@@ -76,26 +76,26 @@  discard block
 block discarded – undo
76 76
      * @param int|null $secretLevel the secret level this query currently running on
77 77
      * @return string|array $result
78 78
      */
79
-    public function getExtra($need, $secretLevel = 0){
80
-        $ret = $this->extras()->orderBy('key')->get()->toArray();
81
-        $result = [];
82
-        if(!empty($ret)){
83
-            if(is_string($need)){
79
+    public function getExtra($need, $secretLevel=0) {
80
+        $ret=$this->extras()->orderBy('key')->get()->toArray();
81
+        $result=[];
82
+        if (!empty($ret)) {
83
+            if (is_string($need)) {
84 84
                 foreach ($ret as $value) {
85
-                    if(empty($value['secret_level']) || $value['secret_level'] <= $secretLevel){
86
-                        $keyName = UserExtra::$extraMapping[$value['key']] ?? 'unknown';
87
-                        if($keyName == $need){
85
+                    if (empty($value['secret_level']) || $value['secret_level']<=$secretLevel) {
86
+                        $keyName=UserExtra::$extraMapping[$value['key']] ?? 'unknown';
87
+                        if ($keyName==$need) {
88 88
                             return $value['value'];
89 89
                         }
90 90
                     }
91 91
                 }
92 92
                 return null;
93
-            }else{
93
+            } else {
94 94
                 foreach ($ret as $value) {
95
-                    if(empty($value['secret_level']) || $value['secret_level'] <= $secretLevel){
96
-                        $keyName = UserExtra::$extraMapping[$value['key']] ?? 'unknown';
97
-                        if(in_array($keyName, $need)){
98
-                            $result[$keyName] = $value['value'];
95
+                    if (empty($value['secret_level']) || $value['secret_level']<=$secretLevel) {
96
+                        $keyName=UserExtra::$extraMapping[$value['key']] ?? 'unknown';
97
+                        if (in_array($keyName, $need)) {
98
+                            $result[$keyName]=$value['value'];
99 99
                         }
100 100
                     }
101 101
                 }
@@ -112,54 +112,54 @@  discard block
 block discarded – undo
112 112
      * @param int|null $secretLevel the secret level this query currently running on
113 113
      * @return mixed $result
114 114
      */
115
-    public function setExtra($keyName, $value = null, $secretLevel = -1){
116
-        $key = array_search($keyName, UserExtra::$extraMapping);
117
-        if($key === false){
115
+    public function setExtra($keyName, $value=null, $secretLevel=-1) {
116
+        $key=array_search($keyName, UserExtra::$extraMapping);
117
+        if ($key===false) {
118 118
             return false;
119 119
         }
120
-        $ret = $this->extras()->where('key', $key)->limit(1)->get()->toArray();
121
-        if(!empty($ret)){
122
-            $ret = $ret[0];
120
+        $ret=$this->extras()->where('key', $key)->limit(1)->get()->toArray();
121
+        if (!empty($ret)) {
122
+            $ret=$ret[0];
123 123
             unset($ret['id']);
124
-            if(!is_null($value)){
125
-                $ret['value'] = $value;
126
-            }else{
124
+            if (!is_null($value)) {
125
+                $ret['value']=$value;
126
+            } else {
127 127
                 $this->extras()->where('key', $key)->delete();
128 128
                 return true;
129 129
             }
130
-            if($secretLevel != -1){
131
-                $ret['secret_level'] = $secretLevel;
130
+            if ($secretLevel!=-1) {
131
+                $ret['secret_level']=$secretLevel;
132 132
             }
133 133
             return $this->extras()->where('key', $key)->update($ret);
134
-        }else{
135
-            if($value === null){
134
+        } else {
135
+            if ($value===null) {
136 136
                 return true;
137 137
             }
138 138
             return $this->extras()->create([
139 139
                 'key' => $key,
140 140
                 'value' => $value,
141
-                'secret_level' => $secretLevel == -1 ? 0 : $secretLevel,
141
+                'secret_level' => $secretLevel==-1 ? 0 : $secretLevel,
142 142
             ])->id;
143 143
         }
144 144
     }
145 145
 
146
-    public function getSocialiteInfo($secretLevel = -1)
146
+    public function getSocialiteInfo($secretLevel=-1)
147 147
     {
148
-        $socialites = [];
148
+        $socialites=[];
149 149
         foreach (UserExtra::$socialite_support as $key => $value) {
150
-            $id_keyname = $key.'_id';
151
-            $id = $this->getExtra($id_keyname);
152
-            if(!empty($id)){
153
-                $info = [
150
+            $id_keyname=$key.'_id';
151
+            $id=$this->getExtra($id_keyname);
152
+            if (!empty($id)) {
153
+                $info=[
154 154
                     'id' => $id,
155 155
                 ];
156 156
                 foreach ($value as $info_name) {
157
-                    $info_temp = $this->getExtra($key.'_'.$info_name);
158
-                    if($info_temp !== null){
159
-                        $info[$info_name] = $info_temp;
157
+                    $info_temp=$this->getExtra($key.'_'.$info_name);
158
+                    if ($info_temp!==null) {
159
+                        $info[$info_name]=$info_temp;
160 160
                     }
161 161
                 }
162
-                $socialites[$key] = $info;
162
+                $socialites[$key]=$info;
163 163
             }
164 164
         }
165 165
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                     }
91 91
                 }
92 92
                 return null;
93
-            }else{
93
+            } else{
94 94
                 foreach ($ret as $value) {
95 95
                     if(empty($value['secret_level']) || $value['secret_level'] <= $secretLevel){
96 96
                         $keyName = UserExtra::$extraMapping[$value['key']] ?? 'unknown';
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             unset($ret['id']);
124 124
             if(!is_null($value)){
125 125
                 $ret['value'] = $value;
126
-            }else{
126
+            } else{
127 127
                 $this->extras()->where('key', $key)->delete();
128 128
                 return true;
129 129
             }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                 $ret['secret_level'] = $secretLevel;
132 132
             }
133 133
             return $this->extras()->where('key', $key)->update($ret);
134
-        }else{
134
+        } else{
135 135
             if($value === null){
136 136
                 return true;
137 137
             }
Please login to merge, or discard this patch.