diff --git a/src/ApiResourceDataTable.php b/src/ApiResourceDataTable.php index 3df4776c..9f51c29c 100644 --- a/src/ApiResourceDataTable.php +++ b/src/ApiResourceDataTable.php @@ -31,14 +31,16 @@ public static function create($source) /** * CollectionEngine constructor. * - * @param \Illuminate\Http\Resources\Json\AnonymousResourceCollection $collection + * @param \Illuminate\Http\Resources\Json\AnonymousResourceCollection $resourceCollection */ - public function __construct(AnonymousResourceCollection $collection) + public function __construct(AnonymousResourceCollection $resourceCollection) { + /** @var \Illuminate\Support\Collection<(int|string), array> $collection */ + $collection = collect($resourceCollection)->pluck('resource'); $this->request = app('datatables.request'); $this->config = app('datatables.config'); - $this->collection = collect($collection); - $this->original = collect($collection); - $this->columns = array_keys($this->serialize(collect($collection)->first())); + $this->collection = $collection; + $this->original = $collection; + $this->columns = array_keys($this->serialize($collection->first())); } }