Adminlte in Laravel sidebar based on permission

derrysan7 picture derrysan7 · Jul 18, 2017 · Viewed 9.8k times · Source

I have multiple users with multiple permission (admin and user). example: admin is able to see sidebar a,b,c but user can only see sidebar d,e,f.

Can you load the menu at adminlte.php based on the permission? I store the permission in permission column inside User table (isAdmin, isUser) Thank you

Menu array format in adminlte.php:

'menu' => [
        [
            'text' => 'Dashboard',
            'url'  => '/dashboard',
            'icon' => 'dashboard',
        ],
],

The only solution that i found is for plain php http://seegatesite.com/how-to-create-user-permissions-view-to-dynamic-sidebar-menu-adminlte/

I would prefer a native laravel solution using the built in adminlte.php

Answer

Mustafa picture Mustafa · Jun 8, 2018

I have integrate Laravel-AdminLTE

to my project. Using this plugin permission could be given like the following:

'can' => 'add-blog-post'

Here is the example:

'menu' => [
    'MAIN NAVIGATION',    
    [
        'text' => 'Pages',
        'url' => 'admin/pages',
        'icon' => 'file',
        'can' => 'add-blog-post'
    ],      
],