Passed
Push — shop ( c2aba6...5180ff )
by Fèvre
04:54
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
     * Show the category by his id and all the related items.
11
     *
12
     * @param string $slug The slug of the category.
13
     * @param int $id The id of the category.
14
     *
15
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
16
     */
17
    public function show(Request $request, string $slug, int $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

17
    public function show(Request $request, /** @scrutinizer ignore-unused */ string $slug, int $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

17
    public function show(/** @scrutinizer ignore-unused */ Request $request, string $slug, int $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...
18
    {
19
        $category = ShopCategory::with('shopItems')
20
            ->where('id', $id)
21
            ->first();
22
23
        if (is_null($category)) {
24
            return redirect()
25
                ->route('shop.index')
26
                ->with('danger', 'This category doesn\'t exist or has been deleted !');
27
        }
28
29
        $items = $category->shopItems()->paginate(config('xetaravel.pagination.shop.item_per_page'));
30
31
        $this->breadcrumbs->addCrumb("Category : " . e($category->title), $category->category_url);
32
33
        return view(
34
            'Shop::category.show',
35
            ['items' => $items, 'category' => $category, 'breadcrumbs' => $this->breadcrumbs]
36
        );
37
    }
38
}
39