public function getAllPermissionsForUser($user)
    {
        $user = $this->resolveUser($user);

        if ( ! $user) {
            return [];
        }

        $permissions = [];

        // Get all permissions for the roles this user belongs to
        foreach ($user->getRoles() as $role) {
            /** @var EloquentRole $role */
            $permissions = array_merge(
                $permissions,
                array_keys(array_filter($role->getPermissions()))
            );
        }

        // Add permissions set specifically for the user
        $permissions = array_merge(
            $permissions,
            array_keys(array_filter($user->getPermissions()))
        );

        sort($permissions);

        return array_unique($permissions);
    }
public function getAllPermissionsForUser($user)
    {
        $user = $this->resolveUser($user);

        if ( ! $user) {
            return [];
        }

        $permissions = [];

        // Get all permissions for the roles this user belongs to
        foreach ($user->getRoles() as $role) {
            /** @var EloquentRole $role */
            $permissions = array_merge(
                $permissions,
                array_keys(array_filter($role->getPermissions()))
            );
        }

        // Add permissions set specifically for the user
        $permissions = array_merge(
            $permissions,
            array_keys(array_filter($user->getPermissions()))
        );

        sort($permissions);

        return array_unique($permissions);
    }
public function getAllPermissionsForUser ( $ user ) { $ user = $ this -> resolveUser ( $ user ) ; if ( ! $ user ) { return [ ] ; } $ permissions = [ ] ; // Get all permissions for the roles this user belongs to foreach ( $ user -> getRoles ( ) as $ role ) { /** @var EloquentRole $role */ $ permissions = array_merge ( $ permissions , array_keys ( array_filter ( $ role -> getPermissions ( ) ) ) ) ; } // Add permissions set specifically for the user $ permissions = array_merge ( $ permissions , array_keys ( array_filter ( $ user -> getPermissions ( ) ) ) ) ; sort ( $ permissions ) ; return array_unique ( $ permissions ) ; }
Returns all permission keys for a given user.

@param string|UserInterface $user user: name or instance
@return string[]
Returns all permission keys for a given user .