Closed drauta closed 8 years ago
Okay no worries I'll need to account for that as well. Cheers.
The workaround I posted yestarday fails in some cases, this not:
if ( ($response instanceof EloquentCollection || ($response instanceof IlluminatePaginator &&
method_exists($response->getCollection(), 'load') ) ) && $this->eagerLoading )
{
$eagerLoads = $this->mergeEagerLoads($transformer, $this->fractal->getRequestedIncludes());
$response->load($eagerLoads);
}
Indeed. No worries I'll have something up when I can.
Thank you!
This is indeed an issue for larger projects, where not only an eloquent collections are used, but hand-made collections of entity objects.
This should've been fixed with cda184a566d9b68f47d4edff51b43ba8f56bbc3c so that it only attempts to eager load Eloquent collections.
Hi, I'm using elasticquent/Elasticquent to do search queries. If you do a search on the model, add pagination and apply a transformer, in the fractal adapter from dingo makes a call to inexistent function:
Line 89 on dingo/api/src/Transformer/Adapter/Fractal.php:
The call to $response->load() fails because the collection is an instance of Illuminate\Support\Collection instead of Illuminate\Database\Eloquent\Collection.
In order to solve this I added a condition to the if:
In summary: when you do pagination on a Illuminate\Support\Collection the fractal paginator fails.
Thank you!!