From 6b6d11e579b129e8e322cee6c5d30a7ddbe86f34 Mon Sep 17 00:00:00 2001 From: liuqing Date: Sun, 10 Mar 2024 22:34:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'app/common/model/Category?= =?UTF-8?q?.php'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update --- app/common/model/Category.php | 11 +++++++++++ 1 file changed, 11 insertions(+) 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