Conditions | 2 |
Paths | 2 |
Total Lines | 27 |
Code Lines | 17 |
Lines | 27 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
23 | View Code Duplication | 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 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: