Completed
Push — master ( 3d4150...00d7a1 )
by Nicolas
03:57
created

SidebarExtender   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A extendWith() 0 23 1
1
<?php namespace Modules\Recipe\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('Recipe', function (Item $item) {
34
                $item->icon('fa fa-copy');
35
                $item->weight(10);
36
                $item->authorize(
37
                    $this->auth->hasAccess('recipe.recipes.index')
38
                );
39
                $item->item(trans('recipe::recipes.title.recipes'), function (Item $item) {
40
                    $item->icon('fa fa-copy');
41
                    $item->weight(0);
42
                    $item->append('admin.recipe.recipe.create');
43
                    $item->route('admin.recipe.recipe.index');
44
                    $item->authorize(
45
                        $this->auth->hasAccess('recipe.recipes.index')
46
                    );
47
                });
48
            });
49
        });
50
51
        return $menu;
52
    }
53
}
54