@@ 23-49 (lines=27) @@ | ||
20 | * |
|
21 | * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View |
|
22 | */ |
|
23 | public function show(Request $request, $slug, $id) |
|
24 | { |
|
25 | $category = Category::with('articles') |
|
26 | ->where('id', $id) |
|
27 | ->first(); |
|
28 | ||
29 | if (is_null($category)) { |
|
30 | return redirect() |
|
31 | ->route('blog_article_index') |
|
32 | ->with('danger', 'This category doesn\'t exist or has been deleted !'); |
|
33 | } |
|
34 | ||
35 | $articles = $category->articles()->paginate(config('xetaravel.pagination.blog.article_per_page')); |
|
36 | ||
37 | $this->breadcrumbs->addCrumb( |
|
38 | "Category : " . e($category->title), |
|
39 | route( |
|
40 | 'blog_article_show', |
|
41 | ['slug' => $category->slug, 'id' => $category->id] |
|
42 | ) |
|
43 | ); |
|
44 | ||
45 | return view( |
|
46 | 'Blog::category.show', |
|
47 | ['articles' => $articles, 'category' => $category, 'breadcrumbs' => $this->breadcrumbs] |
|
48 | ); |
|
49 | } |
|
50 | } |
|
51 |
@@ 35-61 (lines=27) @@ | ||
32 | * |
|
33 | * @return \Illuminate\Http\Response |
|
34 | */ |
|
35 | public function show(Request $request, $slug, $id) |
|
36 | { |
|
37 | $article = Article::with('category', 'user', 'comments') |
|
38 | ->where('id', $id) |
|
39 | ->first(); |
|
40 | ||
41 | if (is_null($article)) { |
|
42 | return redirect() |
|
43 | ->route('blog_article_index') |
|
44 | ->with('danger', 'This article doesn\'t exist or has been deleted !'); |
|
45 | } |
|
46 | ||
47 | $comments = $article->comments()->paginate(config('xetaravel.pagination.blog.comment_per_page')); |
|
48 | ||
49 | $this->breadcrumbs->addCrumb( |
|
50 | "Article : " . e($article->title), |
|
51 | route( |
|
52 | 'blog_article_show', |
|
53 | ['slug' => $article->category->slug, 'id' => $article->category->id] |
|
54 | ) |
|
55 | ); |
|
56 | ||
57 | return view( |
|
58 | 'Blog::article.show', |
|
59 | ['article' => $article, 'comments' => $comments, 'breadcrumbs' => $this->breadcrumbs] |
|
60 | ); |
|
61 | } |
|
62 | } |
|
63 |