krafthaus / bauhaus

Laravel 4 Admin Generator
http://bauhaus.krafthaus.nl/
GNU General Public License v2.0
1 stars 0 forks source link

Menu Permissions #37

Open crofton77 opened 10 years ago

crofton77 commented 10 years ago

As I could not see a way to set access to display menu items I made some changes to the code.

I added the following code to the foreach loop in the buildMenu Function.

$allowed = false;
        if(isset($value['permissions'])){
            $permissions = explode(',',$value['permissions']);

             foreach($permissions AS $p){
                if(\Auth::user()->hasPermission($p)){
                    $allowed = true;
                }
            }
        } else{
            $allowed = true;
        }

I also added the permissions option to the menu config array

'title' => trans('bauhaususer::admin.menu'),
    'permissions' => 'manage_users',
    'children' => [