diff --git a/app/common/model/Category.php b/app/common/model/Category.php index bd49e997..57d78391 100644 --- a/app/common/model/Category.php +++ b/app/common/model/Category.php @@ -69,6 +69,17 @@ class Category extends BaseModel return $this->getTreeData($list); } + public function getChildrenList(array $param = []): array + { + $list = $this->getAll($param)->toArray(); + foreach ($list as &$item) { + $item['children'] = $this->getAll( + [ 'category_id' =>$item['category_id']], + )->toArray(); + } + return $list; + } + /** * 获取所有记录 * @param array $param