order('weigh desc,id asc') ->where('status',StatusEnum::ENABLED) ->select(); $tree->init(collection($categoryList)->toArray(), 'pid'); $list = $tree->getTreeArray(0); $this->success('获取成功', $list); } // 查询所有分类 public function getCategoryList() { $categoryList = CategoryModel::field('id,pid,name,image') ->order('weigh asc,id asc') ->where('status',StatusEnum::ENABLED) ->select(); $this->success('获取成功', $categoryList); } }