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()