分类增加跳转url

This commit is contained in:
2021-10-29 16:57:50 +08:00
parent 9910904ebb
commit ba5abed342
3 changed files with 27 additions and 14 deletions

View File

@@ -11,23 +11,28 @@ class CategoryController extends Controller
//显示分类
public function show(Category $category)
{
if ($category->type == Category::TYPE_SHOW) {
if ($category->relations) {
return redirect(route('article.show', $category->relations));
}
switch ($category->type) {
case Category::TYPE_WEB:
return redirect()->to($category->url);
break;
case Category::TYPE_SHOW:
if ($category->relations) {
return redirect(route('article.show', $category->relations));
}
return redirect('/');
return redirect('/');
break;
default:
$articles = Article::where('category_id', $category->id)
->latest('sort')
->latest()
->paginate();
$parent = $category->getTop();
return view('category.show', compact('category', 'parent', 'articles'));
}
$articles = Article::where('category_id', $category->id)
->latest('sort')
->latest()
->paginate();
$parent = $category->getTop();
return view('category.show', compact('category', 'parent', 'articles'));
}
}