完善
This commit is contained in:
33
app/Http/Controllers/CategoryController.php
Normal file
33
app/Http/Controllers/CategoryController.php
Normal 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'));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user