public function getPermissions()
    {
        // return permissions if they have already been requested
        if(Session::get("usersPermission")) {
            self::$permissions = Session::get("usersPermission");
            return Session::get("usersPermission");
        }
        // return permissions if they have already been requested
        if(self::$permissions) {
            return self::$permissions;
        }

        $groupIDs = [];
        foreach (Auth::user()->roles as $group) {
            if ($group->isDefault) {
                self::$permissions["global"]["isDefault"] = true;
            }
            $groupIDs[] = $group->groupID;
        }

        $permissions = Permission::whereIn("groupID", $groupIDs)->get();

        // save values in keys & values for easy access
        foreach ($permissions as $permission) {
            self::$permissions[$permission->app][$permission->key] = [
              'value' => ($permission->ids !== null) ? array_values(json_decode($permission->ids, true)) : $permission->value,
              'hasAll' => $permission['hasAll']
            ];
        }
        Session::put("usersPermission", self::$permissions);
        return self::$permissions;
    }
public function getPermissions()
    {
        // return permissions if they have already been requested
        if(Session::get("usersPermission")) {
            self::$permissions = Session::get("usersPermission");
            return Session::get("usersPermission");
        }
        // return permissions if they have already been requested
        if(self::$permissions) {
            return self::$permissions;
        }

        $groupIDs = [];
        foreach (Auth::user()->roles as $group) {
            if ($group->isDefault) {
                self::$permissions["global"]["isDefault"] = true;
            }
            $groupIDs[] = $group->groupID;
        }

        $permissions = Permission::whereIn("groupID", $groupIDs)->get();

        // save values in keys & values for easy access
        foreach ($permissions as $permission) {
            self::$permissions[$permission->app][$permission->key] = [
              'value' => ($permission->ids !== null) ? array_values(json_decode($permission->ids, true)) : $permission->value,
              'hasAll' => $permission['hasAll']
            ];
        }
        Session::put("usersPermission", self::$permissions);
        return self::$permissions;
    }
public function getPermissions ( ) { // return permissions if they have already been requested if ( Session :: get ( "usersPermission" ) ) { self :: $ permissions = Session :: get ( "usersPermission" ) ; return Session :: get ( "usersPermission" ) ; } // return permissions if they have already been requested if ( self :: $ permissions ) { return self :: $ permissions ; } $ groupIDs = [ ] ; foreach ( Auth :: user ( ) -> roles as $ group ) { if ( $ group -> isDefault ) { self :: $ permissions [ "global" ] [ "isDefault" ] = true ; } $ groupIDs [ ] = $ group -> groupID ; } $ permissions = Permission :: whereIn ( "groupID" , $ groupIDs ) -> get ( ) ; // save values in keys & values for easy access foreach ( $ permissions as $ permission ) { self :: $ permissions [ $ permission -> app ] [ $ permission -> key ] = [ 'value' => ( $ permission -> ids !== null ) ? array_values ( json_decode ( $ permission -> ids , true ) ) : $ permission -> value , 'hasAll' => $ permission [ 'hasAll' ] ] ; } Session :: put ( "usersPermission" , self :: $ permissions ) ; return self :: $ permissions ; }
Get permissions of the user.

@return array
Get permissions of the user .