文章分类由1变多
This commit is contained in:
@@ -12,7 +12,7 @@ class ArticleController extends Controller
|
||||
//文章列表
|
||||
public function index(Category $category)
|
||||
{
|
||||
$articles = Article::where('category_id', $category->id)
|
||||
$articles = Article::ByCategory($category->id)
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate(5);
|
||||
|
||||
@@ -26,15 +26,12 @@ class ArticleController extends Controller
|
||||
return redirect($article->url);
|
||||
}
|
||||
|
||||
$category = $article->category;
|
||||
$next = Article::where('id', '>', $article->id)
|
||||
->ByCategory($article->categories()->pluck('id'))
|
||||
->where('status', 1)
|
||||
->first();
|
||||
|
||||
$next = Article::where('id', '>', $article->id)
|
||||
->where('category_id', $category->id)
|
||||
->where('status', 1)
|
||||
->first();
|
||||
$parent = getTopCate($category->id);
|
||||
|
||||
return view('articles.show', compact('article', 'category', 'next', 'parent'));
|
||||
return view('articles.show', compact('article', 'next'));
|
||||
}
|
||||
|
||||
//搜索
|
||||
|
||||
Reference in New Issue
Block a user