Ejemplo n.º 1
0
 function getPermissions()
 {
     // GET ALL PERMISSION
     $permissions = Permission::all()->toArray();
     $permissionMap = array();
     // GET ALL MODULE
     $moduleData = Menu::all()->toArray();
     if (!empty($permissions)) {
         foreach ($permissions as $permission) {
             $permissionMap[strtolower($permission['module'])][] = $permission;
         }
     }
     if (!empty($moduleData)) {
         $moduleData = array_column($moduleData, 'module', 'module');
     }
     // get role permission
     $rolePermissions = $this->data['id'] ? $this->data['item']->permissions : [];
     $this->data['permissionMap'] = $permissionMap;
     $this->data['moduleData'] = $moduleData;
     $this->data['rolePermissions'] = $rolePermissions;
     return true;
 }
Ejemplo n.º 2
0
 /**
  * get menus with permission read of user
  *
  * @return array
  */
 public function getMenu()
 {
     $listMenusTMP = Menu::getList();
     $listMenus = new Collection();
     if (!empty($listMenusTMP)) {
         foreach ($listMenusTMP as $menu) {
             $item = clone $menu;
             if (Sentinel::hasAccess(strtolower($menu->module) . ".*")) {
                 $item->children->each(function ($child, $key) use($item) {
                     if (!$child->status || !Sentinel::hasAccess(strtolower($child->module) . ".*")) {
                         $item->children->forget($key);
                     }
                 });
                 $listMenus->add($item);
             }
         }
     }
     return $listMenus;
 }
Ejemplo n.º 3
0
 public function saveNestableAction()
 {
     $listMenus = request('menu');
     $order = 0;
     if (!empty($listMenus)) {
         foreach ($listMenus as $id => $parent) {
             $order++;
             $menu = Menu::where('id', $id)->update(['parent_id' => intval($parent), 'order' => $order]);
         }
     }
     return response()->json(true);
 }