| Conditions | 2 |
| Paths | 2 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 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("Category : " . e($category->title), $category->category_url); |
||
| 38 | |||
| 39 | return view( |
||
| 40 | 'Blog::category.show', |
||
| 41 | ['articles' => $articles, 'category' => $category, 'breadcrumbs' => $this->breadcrumbs] |
||
| 42 | ); |
||
| 43 | } |
||
| 44 | } |
||
| 45 |
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: