I have an Eloquent model that has several relationships to other models, some of which have nested relationships themselves.
Eager loading theses relationships from within Eloquent at getting a collection containing the loaded data seems pretty straight forward.
However when I use this collection with Dingo's response()->collection($collection, $transformer) the eager loaded data is ignored and it falls back to lazy load everything.
public function transform(Model $model) { return ['nested' => $model->relation()->first()->nested]; }
Should that in principle already use eager loading or do I have to use Fractals $defaultIncludes = ['relation']; and includeRelation() mechanism like here?
http://fractal.thephpleague.com/transformers/
I have an Eloquent model that has several relationships to other models, some of which have nested relationships themselves. Eager loading theses relationships from within Eloquent at getting a collection containing the loaded data seems pretty straight forward. However when I use this collection with Dingo's response()->collection($collection, $transformer) the eager loaded data is ignored and it falls back to lazy load everything.
The transform method is like:
Should that in principle already use eager loading or do I have to use Fractals $defaultIncludes = ['relation']; and includeRelation() mechanism like here? http://fractal.thephpleague.com/transformers/