初步完成
This commit is contained in:
@@ -2,20 +2,38 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\Category;
|
||||
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Notes: 分类下的文章
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/6/1 9:19
|
||||
* @param \App\Models\Category $category
|
||||
*/
|
||||
public function articles(Category $category)
|
||||
//显示分类
|
||||
public function show(Category $category)
|
||||
{
|
||||
if ($category->type == Category::TYPE_SHOW) {
|
||||
if ($category->relations) {
|
||||
return route('article.show', $category->relations);
|
||||
}
|
||||
}
|
||||
$parent = getTopCate($category->id);
|
||||
|
||||
$template = array_flip(config('haai.category'));
|
||||
if (isset($template[$category->id])) {
|
||||
return view('category.' . $template[$category->id], compact('category', 'parent'));
|
||||
}
|
||||
|
||||
return redirect(route('category.list', $category));
|
||||
|
||||
}
|
||||
|
||||
//显示文章列表
|
||||
public function list(Category $category)
|
||||
{
|
||||
$articles = Article::where('category_id', $category->id)->where('status', 1)->paginate();
|
||||
$parent = getTopCate($category->id);
|
||||
|
||||
return view('category.list', compact('category', 'parent', 'articles'));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user