Пример #1
0
 function viewcMenu()
 {
     $user = Auth::admin()->user();
     $roles = Role::all();
     foreach ($roles as $value) {
         if ($user->hasRole($value->name)) {
             $dataPermission = Permission::join('permission_role as p', 'permissions.id', '=', 'p.permission_id')->select('permissions.*')->where('p.role_id', '=', $value->id)->get()->toArray();
             foreach ($dataPermission as $value) {
                 if ($user->can($value['name'])) {
                     $menu[] = ['name' => $value['description'], 'modulo' => $value['modulo'], 'controller' => $value['name']];
                 } else {
                     echo "<script language='JavaScript'>history.back(alert('No tienes acceso para esta pagina'));</script>";
                     exit;
                 }
             }
             return $menu;
         }
     }
 }