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);
    }