Completed
Push — master ( e88dbf...166286 )
by Nicolas
02:37
created

SidebarExtender::extendWith()   B

Complexity

Conditions 3
Paths 1

Size

Total Lines 43
Code Lines 29

Duplication

Lines 27
Ratio 62.79 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 27
loc 43
rs 8.8571
cc 3
eloc 29
nc 1
nop 1
1
<?php namespace Modules\Blog\Sidebar;
2
3
use Maatwebsite\Sidebar\Group;
4
use Maatwebsite\Sidebar\Item;
5
use Maatwebsite\Sidebar\Menu;
6
use Modules\Core\Contracts\Authentication;
7
8
class SidebarExtender implements \Maatwebsite\Sidebar\SidebarExtender
9
{
10
    /**
11
     * @var Authentication
12
     */
13
    protected $auth;
14
15
    /**
16
     * @param Authentication $auth
17
     *
18
     * @internal param Guard $guard
19
     */
20
    public function __construct(Authentication $auth)
21
    {
22
        $this->auth = $auth;
23
    }
24
25
    /**
26
     * @param Menu $menu
27
     *
28
     * @return Menu
29
     */
30
    public function extendWith(Menu $menu)
31
    {
32
        $menu->group(trans('core::sidebar.content'), function (Group $group) {
33
            $group->item(trans('blog::blog.title'), function (Item $item) {
34
35
                $item->icon('fa fa-copy');
36
                $item->weight(0);
37
38 View Code Duplication
                $item->item(trans('blog::post.title.post'), function (Item $item) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
                    $item->icon('fa fa-copy');
40
                    $item->weight(0);
41
                    $item->append('admin.blog.post.create');
42
                    $item->route('admin.blog.post.index');
43
                    $item->authorize(
44
                        $this->auth->hasAccess('blog.posts.index')
45
                    );
46
                });
47 View Code Duplication
                $item->item(trans('blog::tag.title.tag'), function (Item $item) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
                    $item->icon('fa fa-tags');
49
                    $item->weight(0);
50
                    $item->append('admin.blog.tag.create');
51
                    $item->route('admin.blog.tag.index');
52
                    $item->authorize(
53
                        $this->auth->hasAccess('blog.tags.index')
54
                    );
55
                });
56 View Code Duplication
                $item->item(trans('blog::category.title.category'), function (Item $item) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
57
                    $item->icon('fa fa-file-text');
58
                    $item->weight(1);
59
                    $item->route('admin.blog.category.index');
60
                    $item->append('admin.blog.category.create');
61
                    $item->authorize(
62
                        $this->auth->hasAccess('blog.categories.index')
63
                    );
64
                });
65
                $item->authorize(
66
                    $this->auth->hasAccess('blog.tags.index') || $this->auth->hasAccess('blog.posts.index') || $this->auth->hasAccess('blog.categories.index')
67
                );
68
            });
69
        });
70
71
        return $menu;
72
    }
73
}
74