牟新芬 3 years ago
parent
commit
abb9bd0823
2 changed files with 5 additions and 3 deletions
  1. 1 1
      app/api/controller/v1/Index.php
  2. 4 2
      app/model/system/Category.php

+ 1 - 1
app/api/controller/v1/Index.php

@@ -18,7 +18,7 @@ class Index extends BaseController
      */
     public function getCategory(){
         $category = new CategoryModel();
-        $menus = $category->getArMenu('',0,1);
+        $menus = $category->getArMenu('', 0, 1);
         return app('json')->success($menus);
     }
 

+ 4 - 2
app/model/system/Category.php

@@ -70,15 +70,17 @@ class Category extends BaseModel
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function getArMenu($cate_name = '',$pid = '',$show =  0){
+    public function getArMenu($cate_name = '',$pid = '',$is_show = 0){
         $menus = $this
-            ->where('is_show', 1)
             ->when(!empty($cate_name),function ($query) use($cate_name){
                 $query->whereLike('cate_name',"%{$cate_name}%");
             })
             ->when(!empty($pid),function ($query) use($pid){
                 $query->where('pid',$pid);
             })
+            ->when(!empty($is_show),function ($query) use($is_show){
+                $query->where('is_show',$is_show);
+            })
             ->order("sort","desc")
             ->select();
         $data = [];