SidebarExtender   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 57
rs 10
c 2
b 1
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B extendWith() 0 34 2
1
<?php namespace Modules\User\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('workshop::workshop.title'), function (Group $group) {
33
34
            $group->item(trans('user::users.title.users'), function (Item $item) {
35
                $item->weight(0);
36
                $item->icon('fa fa-user');
37
                $item->authorize(
38
                    $this->auth->hasAccess('user.users.index') or $this->auth->hasAccess('user.roles.index')
39
                );
40
41
                $item->item(trans('user::users.title.users'), function (Item $item) {
42
                    $item->weight(0);
43
                    $item->icon('fa fa-user');
44
                    $item->route('admin.user.user.index');
45
                    $item->authorize(
46
                        $this->auth->hasAccess('user.users.index')
47
                    );
48
                });
49
50
                $item->item(trans('user::roles.title.roles'), function (Item $item) {
51
                    $item->weight(1);
52
                    $item->icon('fa fa-flag-o');
53
                    $item->route('admin.user.role.index');
54
                    $item->authorize(
55
                        $this->auth->hasAccess('user.roles.index')
56
                    );
57
                });
58
            });
59
60
        });
61
62
        return $menu;
63
    }
64
}
65