优化子分类显示;

This commit is contained in:
2022-05-26 10:53:33 +08:00
parent 2a71b4e65d
commit edf787ac08

View File

@@ -42,7 +42,9 @@ class Index extends Common
$page_title = $current_category->title;
$sub_category = Category::where('pid', $category_id)->where('type', 3)->order('sort asc')->select();
if (empty($this->request->param('sub_category_id'))) {
$sub_category_id = $this->request->param('sub_category_id');
if (empty($sub_category_id)) {
$categorys = [$category_id];
$categorys = array_merge($categorys, array_column((array)Category::getListLevel($category_id), 3));
@@ -51,8 +53,11 @@ class Index extends Common
$model_post = Post::hasWhere('categorys', $categorys_where)->where('status', 1)->order('id desc');
} else {
$page_title .= "|{$sub_category->title}";
$model_post = Post::hasWhere('categorys', ['category_id' => $this->request->param('sub_category_id')])->where('status', 1)->order('id desc');
$model_sub_category = Category::find($sub_category_id);
$page_title .= "|{$model_sub_category->title}";
$model_post = Post::hasWhere('categorys', ['category_id' => $sub_category_id])->where('status', 1)->order('id desc');
}
} else {