protected function extractRelations(array $relations): array
    {
        $available = $this->availableRelations();

        return array_filter($this->mapRelations($relations, function ($relation, $constraint) {
            $identifier = explode('.', $relation)[0];
            $constraint = $identifier === $relation ? $constraint : null;

            return [$identifier => $constraint ?: $this->resolveQueryConstraint($identifier)];
        }), function ($relation) use ($available) {
            return array_has($available, explode(':', $relation)[0]);
        }, ARRAY_FILTER_USE_KEY);
    }