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

ItemController::__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\ShopItem;
5
use Illuminate\Http\Request;
6
7
class ItemController extends Controller
8
{
9
    /**
10
     * Constructor.
11
     */
12
    public function __construct()
13
    {
14
        parent::__construct();
15
16
        $this->breadcrumbs->removeListElementClasses('breadcrumb');
17
        $this->breadcrumbs->addCrumb('Shop', route('shop.item.index'));
18
    }
19
20
    /**
21
     * Show the list of all items.
22
     *
23
     * @return \Illuminate\Http\Response
24
     */
25
    public function index()
26
    {
27
        $articles = ShopItem::with('category', 'user')
28
            ->orderByDesc('created_at')
29
            ->paginate(config('xetaravel.pagination.blog.article_per_page'));
30
31
        return view('Blog::article.index', ['articles' => $articles, 'breadcrumbs' => $this->breadcrumbs]);
32
    }
33
34
    /**
35
     * Show the article by his id.
36
     *
37
     * @return \Illuminate\Http\Response
38
     */
39
    public function show(Request $request, $slug, $id)
40
    {
41
        $article = Article::with('category', 'user', 'comments')
0 ignored issues
show
Bug introduced by
The type Xetaravel\Http\Controllers\Shop\Article was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
42
            ->where('id', $id)
43
            ->first();
44
45
        if (is_null($article)) {
46
            return redirect()
47
                ->route('blog.article.index')
48
                ->with('danger', 'This article doesn\'t exist or has been deleted !');
49
        }
50
51
        $comments = $article->comments()->paginate(config('xetaravel.pagination.blog.comment_per_page'));
52
        $comments->load('user');
53
54
        $breadcrumbs = $this->breadcrumbs->addCrumb("Article : " . e($article->title), $article->article_url);
55
56
        return view('Blog::article.show', compact('article', 'comments', 'breadcrumbs'));
57
    }
58
}
59