SidebarViewComposer.php 1.34 KB
Newer Older
Nicolas Widart's avatar
Nicolas Widart committed
1 2
<?php namespace Modules\User\Composers;

3
use Illuminate\Contracts\View\View;
4
use Illuminate\Support\Collection;
5
use Illuminate\Support\Facades\Request;
6
use Modules\Core\Composers\BaseSidebarViewComposer;
7

8
class SidebarViewComposer extends BaseSidebarViewComposer
Nicolas Widart's avatar
Nicolas Widart committed
9
{
10
    public function compose(View $view)
Nicolas Widart's avatar
Nicolas Widart committed
11
    {
12 13 14
        $view->items->put('user', Collection::make([
            [
                'weight' => '1',
15
                'request' => Request::is("*/{$view->prefix}/users*") or Request::is("*/{$view->prefix}/roles*"),
16 17 18
                'route' => '#',
                'icon-class' => 'fa fa-user',
                'title' => 'Users & Roles',
19
                'permission' => $this->auth->hasAccess('users.index') or $this->auth->hasAccess('roles.index')
20 21
            ],
            [
22
                'request' => "*/{$view->prefix}/users*",
23 24 25
                'route' => 'dashboard.user.index',
                'icon-class' => 'fa fa-user',
                'title' => 'Users',
26
                'permission' => $this->auth->hasAccess('users.index')
27 28
            ],
            [
29
                'request' => "*/{$view->prefix}/roles*",
30
                'route' => 'dashboard.role.index',
31 32
                'icon-class' => 'fa fa-flag-o',
                'title' => 'Roles',
33
                'permission' => $this->auth->hasAccess('roles.index')
34 35
            ]
        ]));
Nicolas Widart's avatar
Nicolas Widart committed
36
    }
37
}