SidebarExtender::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php namespace Modules\Menu\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->weight(90);
34
            $group->item(trans('menu::menu.title'), function (Item $item) {
35
                $item->weight(3);
36
                $item->icon('fa fa-bars');
37
                $item->route('admin.menu.menu.index');
38
                $item->authorize(
39
                    $this->auth->hasAccess('menu.menus.index')
40
                );
41
            });
42
        });
43
44
        return $menu;
45
    }
46
}
47