public function transform(&$results)
{
if ($this->field) {
$fields = FluentArray::from($results)->map(Functions::extractExpression($this->field))->flatten()->filterNotBlank()->toArray();
$this->transformer->transform($fields);
} else {
$this->transformer->transform($results);
}
}
private function _fetchRelations($results, $joinsToStore) { $joinedRelations = Arrays::map($joinsToStore, Functions::extract()->destinationField()); foreach ($this->relationsToFetch as $relationToFetch) { if (!in_array($relationToFetch->destinationField, $joinedRelations)) { $relationFetcher = new RelationFetcher($relationToFetch->relation); $fieldTransformer = new FieldTransformer($relationToFetch->field, $relationFetcher); $fieldTransformer->transform($results); } } return $results; }