diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index 2e2be92..0ff05f3 100644 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -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 {