@@ -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 | } |