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
2
3
namespace Modules\Tag\Sidebar;
4
5
use Maatwebsite\Sidebar\Group;
6
use Maatwebsite\Sidebar\Item;
7
use Maatwebsite\Sidebar\Menu;
8
use Modules\User\Contracts\Authentication;
9
10
class SidebarExtender implements \Maatwebsite\Sidebar\SidebarExtender
11
{
12
    /**
13
     * @var Authentication
14
     */
15
    protected $auth;
16
17
    /**
18
     * @param Authentication $auth
19
     *
20
     * @internal param Guard $guard
21
     */
22
    public function __construct(Authentication $auth)
23
    {
24
        $this->auth = $auth;
25
    }
26
27
    /**
28
     * @param Menu $menu
29
     *
30
     * @return Menu
31
     */
32
    public function extendWith(Menu $menu)
33
    {
34
        $menu->group(trans('core::sidebar.content'), function (Group $group) {
35
            $group->item(trans('tag::tags.tags'), function (Item $item) {
36
                $item->icon('fa fa-tag');
37
                $item->weight(0);
38
                $item->route('admin.tag.tag.index');
39
                $item->authorize(
40
                    $this->auth->hasAccess('tag.tags.index')
41
                );
42
            });
43
        });
44
45
        return $menu;
46
    }
47
}
48