예제 #1
0
파일: helpers.php 프로젝트: josmel/buen
 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;
         }
     }
 }