@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | |
19 | 19 | public function login($all_data) |
20 | 20 | { |
21 | - if(isset($all_data["url"])) $url = $all_data["url"]; else throw new Exception("url is not exist in all_data"); |
|
22 | - if(isset($all_data["data"])) $data = $all_data["data"]; else throw new Exception("data is not exist in all_data"); |
|
23 | - if(isset($all_data["oj"])) $oj = $all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
24 | - if(isset($all_data["ret"])) $ret = $all_data["ret"]; else $ret = 'false'; |
|
25 | - if(isset($all_data["handle"])) $handle = $all_data["handle"]; else $handle = "default"; |
|
21 | + if (isset($all_data["url"])) $url=$all_data["url"]; else throw new Exception("url is not exist in all_data"); |
|
22 | + if (isset($all_data["data"])) $data=$all_data["data"]; else throw new Exception("data is not exist in all_data"); |
|
23 | + if (isset($all_data["oj"])) $oj=$all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
24 | + if (isset($all_data["ret"])) $ret=$all_data["ret"]; else $ret='false'; |
|
25 | + if (isset($all_data["handle"])) $handle=$all_data["handle"]; else $handle="default"; |
|
26 | 26 | |
27 | 27 | $datapost=curl_init(); |
28 | 28 | $headers=array("Expect:"); |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | |
55 | 55 | public function grab_page($all_data) |
56 | 56 | { |
57 | - if(isset($all_data["site"])) $site = $all_data["site"]; else throw new Exception("site is not exist in all_data"); |
|
58 | - if(isset($all_data["oj"])) $oj = $all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
59 | - if(isset($all_data["headers"])) $headers = $all_data["headers"]; else $headers = []; |
|
60 | - if(isset($all_data["handle"])) $handle = $all_data["handle"]; else $handle = "default"; |
|
61 | - if(isset($all_data["follow"])) $follow = $all_data["follow"]; else $follow = false; |
|
62 | - if(isset($all_data["vcid"])) $vcid = $all_data["vcid"]."_"; else $vcid = ""; |
|
57 | + if (isset($all_data["site"])) $site=$all_data["site"]; else throw new Exception("site is not exist in all_data"); |
|
58 | + if (isset($all_data["oj"])) $oj=$all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
59 | + if (isset($all_data["headers"])) $headers=$all_data["headers"]; else $headers=[]; |
|
60 | + if (isset($all_data["handle"])) $handle=$all_data["handle"]; else $handle="default"; |
|
61 | + if (isset($all_data["follow"])) $follow=$all_data["follow"]; else $follow=false; |
|
62 | + if (isset($all_data["vcid"])) $vcid=$all_data["vcid"]."_"; else $vcid=""; |
|
63 | 63 | |
64 | 64 | $handle=urlencode($handle); |
65 | 65 | |
@@ -86,16 +86,16 @@ discard block |
||
86 | 86 | |
87 | 87 | public function post_data($all_data) |
88 | 88 | { |
89 | - if(isset($all_data["site"])) $site = $all_data["site"]; else throw new Exception("site is not exist in all_data"); |
|
90 | - if(isset($all_data["data"])) $data = $all_data["data"]; else throw new Exception("data is not exist in all_data"); |
|
91 | - if(isset($all_data["oj"])) $oj = $all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
92 | - if(isset($all_data["ret"])) $ret = $all_data["ret"]; else $ret = false; |
|
93 | - if(isset($all_data["follow"])) $follow = $all_data["follow"]; else $follow = true; |
|
94 | - if(isset($all_data["returnHeader"])) $returnHeader = $all_data["returnHeader"]; else $returnHeader = true; |
|
95 | - if(isset($all_data["postJson"])) $postJson = $all_data["postJson"]; else $postJson = false; |
|
96 | - if(isset($all_data["extraHeaders"])) $extraHeaders = $all_data["extraHeaders"]; else $extraHeaders = []; |
|
97 | - if(isset($all_data["handle"])) $handle = $all_data["handle"]; else $handle = "default"; |
|
98 | - if(isset($all_data["vcid"])) $vcid = $all_data["vcid"]."_"; else $vcid = ""; |
|
89 | + if (isset($all_data["site"])) $site=$all_data["site"]; else throw new Exception("site is not exist in all_data"); |
|
90 | + if (isset($all_data["data"])) $data=$all_data["data"]; else throw new Exception("data is not exist in all_data"); |
|
91 | + if (isset($all_data["oj"])) $oj=$all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
92 | + if (isset($all_data["ret"])) $ret=$all_data["ret"]; else $ret=false; |
|
93 | + if (isset($all_data["follow"])) $follow=$all_data["follow"]; else $follow=true; |
|
94 | + if (isset($all_data["returnHeader"])) $returnHeader=$all_data["returnHeader"]; else $returnHeader=true; |
|
95 | + if (isset($all_data["postJson"])) $postJson=$all_data["postJson"]; else $postJson=false; |
|
96 | + if (isset($all_data["extraHeaders"])) $extraHeaders=$all_data["extraHeaders"]; else $extraHeaders=[]; |
|
97 | + if (isset($all_data["handle"])) $handle=$all_data["handle"]; else $handle="default"; |
|
98 | + if (isset($all_data["vcid"])) $vcid=$all_data["vcid"]."_"; else $vcid=""; |
|
99 | 99 | |
100 | 100 | $handle=urlencode($handle); |
101 | 101 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $filter["rated"]=isset($all_data["rated"]) ? $all_data["rated"] : null; |
28 | 28 | $filter["anticheated"]=isset($all_data["anticheated"]) ? $all_data["anticheated"] : null; |
29 | 29 | $filter["practice"]=isset($all_data["practice"]) ? $all_data["practice"] : null; |
30 | - $return_list=$contestModel->list($filter,Auth::check()?Auth::user()->id:0); |
|
30 | + $return_list=$contestModel->list($filter, Auth::check() ?Auth::user()->id : 0); |
|
31 | 31 | $featured=$contestModel->featured(); |
32 | 32 | if (is_null($return_list)) { |
33 | 33 | if (isset($all_data["page"]) && $all_data["page"]>1) { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $contestModel=new ContestModel(); |
67 | 67 | $groupModel=new GroupModel(); |
68 | 68 | $clearance=Auth::check() ? $contestModel->judgeClearance($cid, Auth::user()->id) : 0; |
69 | - $basic = $contestModel->basic($cid); |
|
69 | + $basic=$contestModel->basic($cid); |
|
70 | 70 | if (Auth::check()) { |
71 | 71 | $contest_detail=$contestModel->detail($cid, Auth::user()->id); |
72 | 72 | $registration=$contestModel->registration($cid, Auth::user()->id); |
@@ -76,7 +76,7 @@ |
||
76 | 76 | "spj_version" => null, |
77 | 77 | "spj_config" => null |
78 | 78 | ]; |
79 | - if($probBasic["spj"] && $probBasic["spj_version"]){ |
|
79 | + if ($probBasic["spj"] && $probBasic["spj_version"]) { |
|
80 | 80 | $submit_data["spj_version"]=$probBasic["spj_version"]; |
81 | 81 | $submit_data["spj_config"]=$probBasic["spj_lang"]; |
82 | 82 | } |
@@ -64,7 +64,7 @@ |
||
64 | 64 | } |
65 | 65 | public function getLanguageConfigByLanguage($language, $spj=false) |
66 | 66 | { |
67 | - return $this->getLanguageConfigByKey($language.($spj?'_lang_spj_config':'_lang_config')); |
|
67 | + return $this->getLanguageConfigByKey($language.($spj ? '_lang_spj_config' : '_lang_config')); |
|
68 | 68 | } |
69 | 69 | public function getLanguageConfigByKey($key) |
70 | 70 | { |
@@ -13,20 +13,20 @@ |
||
13 | 13 | |
14 | 14 | public function search($key) |
15 | 15 | { |
16 | - $result = []; |
|
17 | - if(strlen($key) >= 2){ |
|
18 | - $ret = self::where('pcode', $key) |
|
19 | - ->orWhereRaw('MATCH(`title`) AGAINST (? IN BOOLEAN MODE)',[$key]) |
|
16 | + $result=[]; |
|
17 | + if (strlen($key)>=2) { |
|
18 | + $ret=self::where('pcode', $key) |
|
19 | + ->orWhereRaw('MATCH(`title`) AGAINST (? IN BOOLEAN MODE)', [$key]) |
|
20 | 20 | ->select('pcode', 'title') |
21 | 21 | ->limit(120) |
22 | 22 | ->get()->all(); |
23 | - if(!empty($ret)){ |
|
24 | - $result += $ret; |
|
23 | + if (!empty($ret)) { |
|
24 | + $result+=$ret; |
|
25 | 25 | } |
26 | 26 | } |
27 | - $problemModel = new ProblemModel(); |
|
27 | + $problemModel=new ProblemModel(); |
|
28 | 28 | foreach ($result as $p_index => $p) { |
29 | - if($problemModel->isBlocked($p['pid']) || $problemModel->isHidden($p["pid"])){ |
|
29 | + if ($problemModel->isBlocked($p['pid']) || $problemModel->isHidden($p["pid"])) { |
|
30 | 30 | unset($result[$p_index]); |
31 | 31 | } |
32 | 32 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | class AccountModel extends Model |
13 | 13 | { |
14 | - private $user_extra = [ |
|
14 | + private $user_extra=[ |
|
15 | 15 | 0 => 'gender', |
16 | 16 | 1 => 'contact', |
17 | 17 | 2 => 'school', |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | 1004 => 'github_token', |
27 | 27 | ]; |
28 | 28 | |
29 | - private $socialite_support = [ |
|
29 | + private $socialite_support=[ |
|
30 | 30 | //use the form "platform_id" for unique authentication |
31 | 31 | //such as github_id |
32 | 32 | 'github' => [ |
33 | - 'email','nickname','homepage','token' |
|
33 | + 'email', 'nickname', 'homepage', 'token' |
|
34 | 34 | ], |
35 | 35 | ]; |
36 | 36 | |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | public function feed($uid=null) |
49 | 49 | { |
50 | 50 | $ret=[]; |
51 | - $solution=DB::table("problem_solution")->join("problem","problem.pid","=","problem_solution.pid")->where(["uid"=>$uid,"audit"=>1])->select("problem.pid as pid","pcode","title","problem_solution.created_at as created_at")->orderBy("problem_solution.created_at","DESC")->get()->all(); |
|
52 | - foreach($solution as &$s){ |
|
51 | + $solution=DB::table("problem_solution")->join("problem", "problem.pid", "=", "problem_solution.pid")->where(["uid"=>$uid, "audit"=>1])->select("problem.pid as pid", "pcode", "title", "problem_solution.created_at as created_at")->orderBy("problem_solution.created_at", "DESC")->get()->all(); |
|
52 | + foreach ($solution as &$s) { |
|
53 | 53 | $s["type"]="event"; |
54 | 54 | $s["color"]="wemd-orange"; |
55 | 55 | $s["icon"]="comment-check-outline"; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | public function generateContestAccount($cid, $ccode, $num) |
62 | 62 | { |
63 | 63 | $ret=[]; |
64 | - $starting=DB::table("users")->where('prefix','=',$ccode)->count(); |
|
64 | + $starting=DB::table("users")->where('prefix', '=', $ccode)->count(); |
|
65 | 65 | $contestModel=new ContestModel(); |
66 | 66 | for ($i=1; $i<=$num; $i++) { |
67 | 67 | $pass=$this->generatePassword(); |
@@ -120,14 +120,14 @@ discard block |
||
120 | 120 | ])->join("problem", "problem.pid", "=", "submission.pid")->select('pcode')->distinct()->get()->all(); |
121 | 121 | $ret["solvedCount"]=count($ret["solved"]); |
122 | 122 | // Casual |
123 | - $ret["rank"]=Cache::tags(['rank',$ret["id"]])->get("rank", "N/A"); |
|
124 | - $ret["rankTitle"]=Cache::tags(['rank',$ret["id"]])->get("title", "Recruit"); |
|
123 | + $ret["rank"]=Cache::tags(['rank', $ret["id"]])->get("rank", "N/A"); |
|
124 | + $ret["rankTitle"]=Cache::tags(['rank', $ret["id"]])->get("title", "Recruit"); |
|
125 | 125 | $ret["rankTitleColor"]=RankModel::getColor($ret["rankTitle"]); |
126 | 126 | // Professional |
127 | 127 | $ret["professionalTitle"]=RankModel::getProfessionalTitle($ret["professional_rate"]); |
128 | 128 | $ret["professionalTitleColor"]=RankModel::getProfessionalColor($ret["professionalTitle"]); |
129 | 129 | // Administration Group |
130 | - $ret["admin"]=$uid==1?1:0; |
|
130 | + $ret["admin"]=$uid==1 ? 1 : 0; |
|
131 | 131 | if (Cache::tags(['bing', 'pic'])->get(date("Y-m-d"))==null) { |
132 | 132 | $bing=new BingPhoto([ |
133 | 133 | 'locale' => 'zh-CN', |
@@ -146,26 +146,26 @@ discard block |
||
146 | 146 | * @param string|array $need An array is returned when an array is passed in,Only one value is returned when a string is passed in. |
147 | 147 | * @return string|array $result |
148 | 148 | */ |
149 | - public function getExtra($uid,$need, $secret_level = 0){ |
|
150 | - $ret = DB::table('users_extra')->where('uid',$uid)->orderBy('key')->get()->all(); |
|
151 | - $result = []; |
|
152 | - if(!empty($ret)){ |
|
153 | - if(is_string($need)){ |
|
149 | + public function getExtra($uid, $need, $secret_level=0) { |
|
150 | + $ret=DB::table('users_extra')->where('uid', $uid)->orderBy('key')->get()->all(); |
|
151 | + $result=[]; |
|
152 | + if (!empty($ret)) { |
|
153 | + if (is_string($need)) { |
|
154 | 154 | foreach ($ret as $value) { |
155 | - if(empty($value['secret_level']) || $value['secret_level'] <= $secret_level){ |
|
156 | - $key_name = $this->user_extra[$value['key']] ?? 'unknown'; |
|
157 | - if($key_name == $need){ |
|
155 | + if (empty($value['secret_level']) || $value['secret_level']<=$secret_level) { |
|
156 | + $key_name=$this->user_extra[$value['key']] ?? 'unknown'; |
|
157 | + if ($key_name==$need) { |
|
158 | 158 | return $value['value']; |
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |
162 | 162 | return null; |
163 | - }else{ |
|
163 | + } else { |
|
164 | 164 | foreach ($ret as $value) { |
165 | - if(empty($value['secret_level']) || $value['secret_level'] <= $secret_level){ |
|
166 | - $key_name = $this->user_extra[$value['key']] ?? 'unknown'; |
|
167 | - if(in_array($key_name,$need)){ |
|
168 | - $result[$key_name] = $value['value']; |
|
165 | + if (empty($value['secret_level']) || $value['secret_level']<=$secret_level) { |
|
166 | + $key_name=$this->user_extra[$value['key']] ?? 'unknown'; |
|
167 | + if (in_array($key_name, $need)) { |
|
168 | + $result[$key_name]=$value['value']; |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | } |
@@ -182,26 +182,26 @@ discard block |
||
182 | 182 | * @param string|null $value the extra info will be delete when value is null |
183 | 183 | * @return mixed $result |
184 | 184 | */ |
185 | - public function setExtra($uid,$key_name,$value = null,$secret_level = -1){ |
|
186 | - $key = array_search($key_name,$this->user_extra); |
|
187 | - if($key === false){ |
|
185 | + public function setExtra($uid, $key_name, $value=null, $secret_level=-1) { |
|
186 | + $key=array_search($key_name, $this->user_extra); |
|
187 | + if ($key===false) { |
|
188 | 188 | return false; |
189 | 189 | } |
190 | - $ret = DB::table('users_extra')->where('uid',$uid)->where('key',$key)->first(); |
|
191 | - if(!empty($ret)){ |
|
190 | + $ret=DB::table('users_extra')->where('uid', $uid)->where('key', $key)->first(); |
|
191 | + if (!empty($ret)) { |
|
192 | 192 | unset($ret['id']); |
193 | - if(!is_null($value)){ |
|
194 | - $ret['value'] = $value; |
|
195 | - }else{ |
|
196 | - DB::table('users_extra')->where('uid',$uid)->where('key',$key)->delete(); |
|
193 | + if (!is_null($value)) { |
|
194 | + $ret['value']=$value; |
|
195 | + } else { |
|
196 | + DB::table('users_extra')->where('uid', $uid)->where('key', $key)->delete(); |
|
197 | 197 | return true; |
198 | 198 | } |
199 | - if($secret_level != -1){ |
|
200 | - $ret['secret_level'] = $secret_level; |
|
199 | + if ($secret_level!=-1) { |
|
200 | + $ret['secret_level']=$secret_level; |
|
201 | 201 | } |
202 | - return DB::table('users_extra')->where('uid',$uid)->where('key',$key)->update($ret); |
|
203 | - }else{ |
|
204 | - if($value === null){ |
|
202 | + return DB::table('users_extra')->where('uid', $uid)->where('key', $key)->update($ret); |
|
203 | + } else { |
|
204 | + if ($value===null) { |
|
205 | 205 | return true; |
206 | 206 | } |
207 | 207 | return DB::table('users_extra')->insertGetId( |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | 'uid' => $uid, |
210 | 210 | 'key' => $key, |
211 | 211 | 'value' => $value, |
212 | - 'secret_level' => $secret_level == -1 ? 0 : $secret_level, |
|
212 | + 'secret_level' => $secret_level==-1 ? 0 : $secret_level, |
|
213 | 213 | ] |
214 | 214 | ); |
215 | 215 | } |
@@ -221,33 +221,33 @@ discard block |
||
221 | 221 | * @param string $value the value |
222 | 222 | * @return string $result |
223 | 223 | */ |
224 | - public function findExtra($key,$value) |
|
224 | + public function findExtra($key, $value) |
|
225 | 225 | { |
226 | - $key = array_search($key,$this->user_extra); |
|
227 | - if($key){ |
|
228 | - return DB::table('users_extra')->where('key',$key)->where('value',$value)->first(); |
|
229 | - }else{ |
|
226 | + $key=array_search($key, $this->user_extra); |
|
227 | + if ($key) { |
|
228 | + return DB::table('users_extra')->where('key', $key)->where('value', $value)->first(); |
|
229 | + } else { |
|
230 | 230 | return null; |
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
234 | - public function getSocialiteInfo($uid,$secret_level = -1) |
|
234 | + public function getSocialiteInfo($uid, $secret_level=-1) |
|
235 | 235 | { |
236 | - $socialites = []; |
|
236 | + $socialites=[]; |
|
237 | 237 | foreach ($this->socialite_support as $key => $value) { |
238 | - $id_keyname = $key.'_id'; |
|
239 | - $id = $this->getExtra($uid,$id_keyname); |
|
240 | - if(!empty($id)){ |
|
241 | - $info = [ |
|
238 | + $id_keyname=$key.'_id'; |
|
239 | + $id=$this->getExtra($uid, $id_keyname); |
|
240 | + if (!empty($id)) { |
|
241 | + $info=[ |
|
242 | 242 | 'id' => $id, |
243 | 243 | ]; |
244 | 244 | foreach ($value as $info_name) { |
245 | - $info_temp = $this->getExtra($uid,$key.'_'.$info_name); |
|
246 | - if($info_temp !== null){ |
|
247 | - $info[$info_name] = $info_temp; |
|
245 | + $info_temp=$this->getExtra($uid, $key.'_'.$info_name); |
|
246 | + if ($info_temp!==null) { |
|
247 | + $info[$info_name]=$info_temp; |
|
248 | 248 | } |
249 | 249 | } |
250 | - $socialites[$key] = $info; |
|
250 | + $socialites[$key]=$info; |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | $grid->column('sid', "ID")->sortable(); |
84 | 84 | $grid->time("Time"); |
85 | 85 | $grid->memory("Memory"); |
86 | - $grid->verdict("Verdict")->display(function ($verdict) { |
|
86 | + $grid->verdict("Verdict")->display(function($verdict) { |
|
87 | 87 | return '<i class="fa fa-circle '.$this->color.'"></i> '.$verdict; |
88 | 88 | }); |
89 | 89 | $grid->language("Language"); |
90 | - $grid->submission_date("Submission Date")->display(function ($submission_date) { |
|
90 | + $grid->submission_date("Submission Date")->display(function($submission_date) { |
|
91 | 91 | return date("Y-m-d H:i:s", $submission_date); |
92 | 92 | }); |
93 | 93 | ; |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | $grid->jid("JID"); |
98 | 98 | $grid->coid("COID"); |
99 | 99 | $grid->score("Raw Score"); |
100 | - $grid->filter(function (Grid\Filter $filter) { |
|
101 | - $filter->column(6, function ($filter) { |
|
100 | + $grid->filter(function(Grid\Filter $filter) { |
|
101 | + $filter->column(6, function($filter) { |
|
102 | 102 | $filter->like('verdict'); |
103 | 103 | }); |
104 | - $filter->column(6, function ($filter) { |
|
104 | + $filter->column(6, function($filter) { |
|
105 | 105 | $filter->equal('cid', 'Contest ID'); |
106 | 106 | $filter->equal('uid', 'User ID'); |
107 | 107 | $filter->equal('pid', 'Problem ID'); |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | $show->coid('COID'); |
139 | 139 | $show->vcid('VCID'); |
140 | 140 | $show->score(); |
141 | - $show->share()->using(['No','Yes']); |
|
141 | + $show->share()->using(['No', 'Yes']); |
|
142 | 142 | return $show; |
143 | 143 | } |
144 | 144 | |
145 | 145 | private function codify($field, $lang=null) |
146 | 146 | { |
147 | - $field->unescape()->as(function ($value) use ($field,$lang) { |
|
148 | - $field->border = false; |
|
147 | + $field->unescape()->as(function($value) use ($field, $lang) { |
|
148 | + $field->border=false; |
|
149 | 149 | $hash=md5($value); |
150 | 150 | if (blank($value)) { |
151 | 151 | $value=" "; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | { |
187 | 187 | $form=new Form(new EloquentSubmissionModel); |
188 | 188 | $form->model()->makeVisible('password'); |
189 | - $form->tab('Basic', function (Form $form) { |
|
189 | + $form->tab('Basic', function(Form $form) { |
|
190 | 190 | $form->display('sid'); |
191 | 191 | $form->text('time')->rules('required'); |
192 | 192 | $form->text('memory')->rules('required'); |
@@ -17,7 +17,7 @@ |
||
17 | 17 | $router->resource('contests', ContestController::class); |
18 | 18 | $router->resource('groups', GroupController::class); |
19 | 19 | |
20 | - Route::group(['prefix' => 'babel'], function (Router $router) { |
|
20 | + Route::group(['prefix' => 'babel'], function(Router $router) { |
|
21 | 21 | $router->get('/', 'BabelController@index')->name('admin.babel.index'); |
22 | 22 | $router->get('installed', 'BabelController@installed')->name('admin.babel.installed'); |
23 | 23 | $router->get('marketspace', 'BabelController@marketspace')->name('admin.babel.marketspace'); |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public static function send($config) |
19 | 19 | { |
20 | - $message = new MessageModel; |
|
21 | - $message->sender = $config['sender']; |
|
22 | - $message->receiver = $config['receiver']; |
|
23 | - $message->title = $config['title']; |
|
24 | - $message->content = $config['content']; |
|
20 | + $message=new MessageModel; |
|
21 | + $message->sender=$config['sender']; |
|
22 | + $message->receiver=$config['receiver']; |
|
23 | + $message->title=$config['title']; |
|
24 | + $message->content=$config['content']; |
|
25 | 25 | /* |
26 | 26 | if(isset($config['reply'])){ |
27 | 27 | $message->reply = $config['reply']; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $message->reply = $config['allow_reply']; |
31 | 31 | } |
32 | 32 | */ |
33 | - $message->official = 1; |
|
33 | + $message->official=1; |
|
34 | 34 | $message->save(); |
35 | 35 | return true; |
36 | 36 | } |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public static function allowReply($id) |
63 | 63 | { |
64 | - $message = static::where('id',$id)->first(); |
|
65 | - if(empty($message)){ |
|
64 | + $message=static::where('id', $id)->first(); |
|
65 | + if (empty($message)) { |
|
66 | 66 | return false; |
67 | 67 | } |
68 | 68 | return $message['allow_reply'] ? true : false; |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public static function list($uid) |
79 | 79 | { |
80 | - return static::join('users','message.sender','=','users.id') |
|
81 | - ->where('receiver',$uid) |
|
80 | + return static::join('users', 'message.sender', '=', 'users.id') |
|
81 | + ->where('receiver', $uid) |
|
82 | 82 | ->select( |
83 | 83 | 'message.id as id', |
84 | 84 | 'users.name as sender_name', |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public static function read($mid) |
105 | 105 | { |
106 | - $message = static::find($mid); |
|
107 | - if(!empty($message)){ |
|
108 | - $message->unread = 0; |
|
106 | + $message=static::find($mid); |
|
107 | + if (!empty($message)) { |
|
108 | + $message->unread=0; |
|
109 | 109 | $message->save(); |
110 | 110 | } |
111 | - return static::join('users','message.sender','=','users.id') |
|
112 | - ->where('message.id',$mid) |
|
111 | + return static::join('users', 'message.sender', '=', 'users.id') |
|
112 | + ->where('message.id', $mid) |
|
113 | 113 | ->select( |
114 | 114 | 'message.id as id', |
115 | 115 | 'users.name as sender_name', |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public static function allRead($uid) |
135 | 135 | { |
136 | - return static::where('receiver',$uid) |
|
136 | + return static::where('receiver', $uid) |
|
137 | 137 | ->update(['unread' => 0]); |
138 | 138 | } |
139 | 139 | |
@@ -161,20 +161,20 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public static function remove($messages) |
163 | 163 | { |
164 | - $del_count = 0; |
|
165 | - if(is_array($messages)){ |
|
164 | + $del_count=0; |
|
165 | + if (is_array($messages)) { |
|
166 | 166 | foreach ($messages as $mid) { |
167 | - $message = static::find($mid); |
|
168 | - if(!empty($message)){ |
|
167 | + $message=static::find($mid); |
|
168 | + if (!empty($message)) { |
|
169 | 169 | $message->delete(); |
170 | - $del_count ++; |
|
170 | + $del_count++; |
|
171 | 171 | } |
172 | 172 | } |
173 | - }else{ |
|
174 | - $message = static::find($messages); |
|
175 | - if(!empty($message)){ |
|
173 | + } else { |
|
174 | + $message=static::find($messages); |
|
175 | + if (!empty($message)) { |
|
176 | 176 | $message->delete(); |
177 | - $del_count ++; |
|
177 | + $del_count++; |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | return $del_count; |