初步完成
This commit is contained in:
@@ -16,8 +16,10 @@ class ArticleController extends Controller
|
||||
*/
|
||||
public function show(Article $article)
|
||||
{
|
||||
$category = $article->category;
|
||||
$parent = getTopCate($category->id);
|
||||
$parent = $category = $article->category;
|
||||
if ($category->id) {
|
||||
$parent = getTopCate($category->id);
|
||||
}
|
||||
|
||||
$next = Article::where('id', '>', $article->id)
|
||||
->where('category_id', $article->category_id)
|
||||
@@ -36,6 +38,7 @@ 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'));
|
||||
|
||||
@@ -18,15 +18,23 @@ class CategoryController extends Controller
|
||||
if ($category->type == Category::TYPE_SHOW && $category->article_id) {
|
||||
return redirect("articles/" . $category->article_id);
|
||||
} else {
|
||||
$articles = $category->relations(Category::TYPE_ARTICLE)->where('status', 1)->latest()->paginate(8);
|
||||
$parent = $category;
|
||||
$template = 'show';
|
||||
if ($category->template) {
|
||||
$template = $category->template;
|
||||
}
|
||||
$articles = $category->relations(Category::TYPE_ARTICLE)
|
||||
->where('status', 1)
|
||||
->latest()
|
||||
->paginate(8);
|
||||
|
||||
$parent = $category;
|
||||
if ($category->childrens->isEmpty() && $category->parent) {
|
||||
$parent = $category->parent;
|
||||
}
|
||||
|
||||
$advert = Advert::where('category_id', 73)->first();
|
||||
|
||||
return view('category.show', compact('articles', 'category', 'parent', 'advert'));
|
||||
return view('category.' . $template, compact('articles', 'category', 'parent', 'advert'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user