Created
June 22, 2016 14:13
-
-
Save dakota/cbfa036e0f0927372ff728b81cdeedf4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$property = $options['propertyPath']; | |
$propertyPath = explode('.', $property); | |
$query->formatResults(function ($results) use ($formatters, $property, $propertyPath) { | |
$extracted = []; | |
foreach ($results as $result) { | |
foreach ($propertyPath as $propertyPathItem) { | |
$result = $result[$propertyPathItem]; | |
} | |
$extracted[] = $result; | |
} | |
$extracted = new Collection($extracted); | |
foreach ($formatters as $callable) { | |
$extracted = new ResultSetDecorator($callable($extracted)); | |
} | |
return $results->insert($property, $extracted); | |
}, Query::PREPEND); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment