调整分类

This commit is contained in:
2021-04-01 17:03:48 +08:00
parent 782fa9e088
commit 507811b713
11 changed files with 181 additions and 66 deletions

View File

@@ -16,17 +16,15 @@ class ArticleController extends Controller
*/
public function show(Article $article)
{
$parent = $category = $article->category;
if ($category->id) {
$parent = getTopCate($category->id);
}
$categories = $article->categories;
$next = Article::where('id', '>', $article->id)
->whereHas('categories', function ($q) use ($categories) {
$q->whereIN('id', $categories->pluck('id'));
})
->where('status', 1)
->first();
$next = Article::where('id', '>', $article->id)
->where('category_id', $article->category_id)
->where('status', 1)
->first();
return view('article.show', compact('article', 'next', 'parent', 'category'));
return view('article.show', compact('article', 'next'));
}
@@ -38,7 +36,6 @@ class ArticleController extends Controller
->when($title, function ($q) use ($title) {
$q->where('title', 'like', "%{$title}%");
})
->where('category_id', '>', 0)
->paginate();
return view('article.search', compact('articles'));