Passed
Pull Request — master (#92)
by Fèvre
09:52 queued 05:01
created

CategoryController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
namespace Xetaravel\Http\Controllers\Shop;
3
4
use Xetaravel\Models\ShopCategory;
5
use Illuminate\Http\Request;
6
7
class CategoryController extends Controller
8
{
9
10
    public function __construct()
11
    {
12
        parent::__construct();
13
14
        $this->breadcrumbs->removeListElementClasses('breadcrumb');
15
        $this->breadcrumbs->addCrumb('Blog', route('blog.article.index'));
16
    }
17
18
    /**
19
     * Show the article by his id.
20
     *
21
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
22
     */
23
    public function show(Request $request, $slug, $id)
0 ignored issues
show
Unused Code introduced by
The parameter $slug is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

23
    public function show(Request $request, /** @scrutinizer ignore-unused */ $slug, $id)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

23
    public function show(/** @scrutinizer ignore-unused */ Request $request, $slug, $id)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
24
    {
25
        $category = ShopCategory::with('items')
26
            ->where('id', $id)
27
            ->first();
28
29
        if (is_null($category)) {
30
            return redirect()
31
                ->route('shop.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