Skip to content

Commit

Permalink
Merge pull request #3 from clickbar/fix-double-get-query
Browse files Browse the repository at this point in the history
fix: Double get query for resource classes
  • Loading branch information
fl0cke authored Oct 5, 2023
2 parents f18fa0d + e229967 commit addd825
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/AgGridExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Maatwebsite\Excel\Concerns\WithMapping;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;

class AgGridExport implements FromQuery, WithHeadings, WithColumnFormatting, ShouldAutoSize, WithMapping
class AgGridExport implements FromQuery, ShouldAutoSize, WithColumnFormatting, WithHeadings, WithMapping
{
/**
* @var Collection<string, AgGridColumnDefinition>
Expand Down
4 changes: 2 additions & 2 deletions src/AgGridQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ public function toResponse($request): mixed
$resourceClass = $this->resourceClass;
if (is_a($resourceClass, ResourceCollection::class, true)) {
// the resource is already a collection
$data = new $resourceClass($this->get());
$data = new $resourceClass($data);
} else {
// wrap in an anonymous collection
$data = $resourceClass::collection($this->get());
$data = $resourceClass::collection($data);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestClasses/Models/Flamingo.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class Flamingo extends Model implements AgGridExportable, AgGridCustomFilterable
class Flamingo extends Model implements AgGridCustomFilterable, AgGridExportable
{
use HasFactory;
use SoftDeletes;
Expand Down

0 comments on commit addd825

Please sign in to comment.