src/Transformers/Concerns/HasRelationships.php
protected function nestedRelations(array $requested, array $available, string $method): array
    {
        $transformers = $this->mappedTransformers($available);

        return collect(array_keys($transformers))->reduce(function ($nestedRelations, $relation) use ($requested, $method, $transformers) {
            $transformer = $transformers[$relation];
            $children = $this->extractChildRelations($requested, $relation);
            $childRelations = $this->wrapChildRelations($transformer->$method($children), $relation);

            return array_merge($nestedRelations, $childRelations);
        }, []);
    }
protected function nestedRelations(array $requested, array $available, string $method): array
    {
        $transformers = $this->mappedTransformers($available);

        return collect(array_keys($transformers))->reduce(function ($nestedRelations, $relation) use ($requested, $method, $transformers) {
            $transformer = $transformers[$relation];
            $children = $this->extractChildRelations($requested, $relation);
            $childRelations = $this->wrapChildRelations($transformer->$method($children), $relation);

            return array_merge($nestedRelations, $childRelations);
        }, []);
    }
Get nested relations from transformers resolved from the $available parameter that
also occur in the $requested parameter.

@param  array  $requested
@param  array  $available
@param  string $method
@return array