From e188a9a3f21366bee3b8a59fac41952fc1ab5cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=84=E5=B0=98?= <122383162@qq.com> Date: Thu, 4 Feb 2021 10:57:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Helpers/function.php | 1 + app/Http/Controllers/CategoryController.php | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Helpers/function.php b/app/Helpers/function.php index e3d2368..5b8551f 100644 --- a/app/Helpers/function.php +++ b/app/Helpers/function.php @@ -181,6 +181,7 @@ function getArtilesByCates($cate_id, $take = 8) { $cate_ids = Category::where('parent_id', $cate_id) ->orWhere('id', $cate_id) + ->where('status', 1) ->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW]) ->pluck('id') ->toArray(); diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index f59ec6b..0221a98 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -38,7 +38,14 @@ class CategoryController extends Controller $template = 'category.persons'; } - $articles = Article::where('category_id', $category->id) + $cate_ids = Category::where('parent_id', $category->id) + ->orWhere('id', $category->id) + ->where('status', 1) + ->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW]) + ->pluck('id') + ->toArray(); + + $articles = Article::whereIn('category_id', $cate_ids) ->where('status', 1) ->latest('sort') ->latest()