瀏覽代碼

无结果返回"count"=>0

visuddhinanda 2 年之前
父節點
當前提交
20b5a56b58
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      app/Http/Controllers/SearchController.php

+ 5 - 1
app/Http/Controllers/SearchController.php

@@ -227,8 +227,12 @@ class SearchController extends Controller
                 break;
                 break;
         }
         }
 
 
+        if($result){
+            return $this->ok(["rows"=>SearchBookResource::collection($result),"count"=>count($result)]);
+        }else{
+            return $this->ok(["rows"=>[],"count"=>0]);
+        }
 
 
-        return $this->ok(["rows"=>SearchBookResource::collection($result),"count"=>count($result)]);
     }
     }
 
 
     private function getQueryWhere($key,$match){
     private function getQueryWhere($key,$match){