Skip to content

Commit

Permalink
Merge pull request #2944 from hpacleb/fix-anonymous-resource-collecti…
Browse files Browse the repository at this point in the history
…on-datatable

fix: Fix anonymous resource collection data formatting
  • Loading branch information
yajra authored Feb 20, 2023
2 parents 11fb5b9 + a3980bb commit 16d6a97
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/ApiResourceDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ public static function create($source)
/**
* CollectionEngine constructor.
*
* @param \Illuminate\Http\Resources\Json\AnonymousResourceCollection<array-key, array> $collection
* @param \Illuminate\Http\Resources\Json\AnonymousResourceCollection<array-key, array> $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()));
}
}

0 comments on commit 16d6a97

Please sign in to comment.