This commit is contained in:
2020-09-16 08:37:18 +08:00
parent fd2e97e190
commit ea72828001
13 changed files with 1289 additions and 136 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Http\Controllers;
use App\Models\Article;
use App\Models\Category;
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));
}
return redirect('/');
}
$articles = Article::where('category_id', $category->id)
->latest('sort')
->latest()
->paginate();
$parent = $category->getTop();
return view('category.show', compact('category', 'parent', 'articles'));
}
}