From 9f92a87151142fc89b551bd3a542de723e1a002c Mon Sep 17 00:00:00 2001 From: limu Date: Tue, 30 Jan 2024 15:08:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=AE=E5=8A=A9=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/model/Article.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/api/model/Article.php b/app/api/model/Article.php index 447bdbe8..58daf544 100644 --- a/app/api/model/Article.php +++ b/app/api/model/Article.php @@ -14,6 +14,7 @@ namespace app\api\model; use cores\exception\BaseException; use app\common\model\Article as ArticleModel; +use app\api\model\article\Category as CategoryModel; /** * 商品评价模型 @@ -97,12 +98,14 @@ class Article extends ArticleModel public function helpCenter() { - $list = $this->withoutField(['content']) - ->where('status', '=', 1) - ->where('is_delete', '=', 0) - ->order(['sort' => 'asc', 'create_time' => 'desc']) - ->select()->toArray(); - $data = static::preload($list, ['image', 'category']); - return $data; + $cat = CategoryModel::where(['status' => 1])->order('sort desc')->select()->toArray(); + foreach ($cat as $k => $v) { + $cat[$k]['child'] = $this->where('status', '=', 1) + ->where('is_delete', '=', 0) + ->where('category_id', '=', $v['category_id']) + ->order(['sort' => 'asc', 'create_time' => 'desc']) + ->select()->toArray(); + } + return $cat; } } \ No newline at end of file