diff --git a/src/Transformer/Adapter/Fractal.php b/src/Transformer/Adapter/Fractal.php index a8f70e5e1..be3ed5e74 100644 --- a/src/Transformer/Adapter/Fractal.php +++ b/src/Transformer/Adapter/Fractal.php @@ -116,7 +116,11 @@ protected function shouldEagerLoad($response) if ($response instanceof IlluminatePaginator) { $response = $response->getCollection(); } - + + if ($response instanceof EloquentCollection && method_exists($response->first(), 'apiEagerLoad')) { + $this->eagerLoading = (bool) $response->first()->apiEagerLoad(); + } + return $response instanceof EloquentCollection && $this->eagerLoading; }