Browse Source

修改数据

Anyon 3 years ago
parent
commit
fa46967111
2 changed files with 4 additions and 4 deletions
  1. 1 1
      app/data/controller/api/Goods.php
  2. 3 3
      app/data/model/ShopGoodsCate.php

+ 1 - 1
app/data/controller/api/Goods.php

@@ -24,7 +24,7 @@ class Goods extends Controller
      */
     public function getCate()
     {
-        $this->success('获取分类成功', ShopGoodsCate::treeJson());
+        $this->success('获取分类成功', ShopGoodsCate::treeData());
     }
 
     /**

+ 3 - 3
app/data/model/ShopGoodsCate.php

@@ -41,9 +41,9 @@ class ShopGoodsCate extends Model
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public static function treeJson(): array
+    public static function treeData(): array
     {
-        $query = static::mk()->where(['deleted' => 0, 'status' => 1])->order('sort desc,id desc');
+        $query = static::mk()->where(['status' => 1, 'deleted' => 0])->order('sort desc,id desc');
         return DataExtend::arr2tree($query->withoutField('sort,status,deleted,create_at')->select()->toArray());
     }
 
@@ -54,7 +54,7 @@ class ShopGoodsCate extends Model
      */
     public static function treeTable(bool $simple = false): array
     {
-        $query = static::mk()->where(['status' => 1])->order('sort desc,id asc');
+        $query = static::mk()->where(['status' => 1, 'deleted' => 0])->order('sort desc,id asc');
         $cates = array_column(DataExtend::arr2table($query->column('id,pid,name', 'id')), null, 'id');
         foreach ($cates as $cate) isset($cates[$cate['pid']]) && $cates[$cate['id']]['parent'] =& $cates[$cate['pid']];
         foreach ($cates as $key => $cate) {