微调
This commit is contained in:
@@ -19,8 +19,8 @@ class CategoryController extends Controller
|
|||||||
$parent = getTopCate($category->id);
|
$parent = getTopCate($category->id);
|
||||||
|
|
||||||
$template = array_flip(config('haai.category'));
|
$template = array_flip(config('haai.category'));
|
||||||
if (isset($template[$category->id]) && !in_array($category->id, config('haai.no_list'))) {
|
if (isset($template[$category->id]) && ! in_array($category->id, config('haai.no_list'))) {
|
||||||
return view('category.' . $template[$category->id], compact('category', 'parent'));
|
return view('category.'.$template[$category->id], compact('category', 'parent'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect(route('category.list', $category));
|
return redirect(route('category.list', $category));
|
||||||
@@ -39,17 +39,17 @@ class CategoryController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$cate_ids = Category::where('parent_id', $category->id)
|
$cate_ids = Category::where('parent_id', $category->id)
|
||||||
->orWhere('id', $category->id)
|
->orWhere('id', $category->id)
|
||||||
->where('status', 1)
|
->where('status', 1)
|
||||||
->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW])
|
->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW])
|
||||||
->pluck('id')
|
->pluck('id')
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
$articles = Article::where('status', 1)
|
$articles = Article::where('status', 1)
|
||||||
->ByCategory($cate_ids)
|
->ByCategory($cate_ids)
|
||||||
->latest('sort')
|
->latest('sort')
|
||||||
->latest()
|
->latest()
|
||||||
->paginate($take);
|
->paginate($take);
|
||||||
|
|
||||||
$parent = getTopCate($category->id);
|
$parent = getTopCate($category->id);
|
||||||
|
|
||||||
@@ -57,6 +57,10 @@ class CategoryController extends Controller
|
|||||||
$parent = $category->parent;
|
$parent = $category->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($category->children->isEmpty()) {
|
||||||
|
$parent = $category->parent;
|
||||||
|
}
|
||||||
|
|
||||||
return view($template, compact('category', 'parent', 'articles'));
|
return view($template, compact('category', 'parent', 'articles'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user