Skip to content

Commit

Permalink
Fix issue with cursor pagination and Json resources (#38026)
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints authored Jul 15, 2021
1 parent 4948698 commit 345c086
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Illuminate/Pagination/AbstractCursorPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\Pivot;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -197,6 +198,10 @@ public function getParametersForItem($item)
return collect($this->parameters)
->flip()
->map(function ($_, $parameterName) use ($item) {
if ($item instanceof JsonResource) {
$item = $item->resource;
}

if ($item instanceof Model &&
! is_null($parameter = $this->getPivotParameterForItem($item, $parameterName))) {
return $parameter;
Expand Down

0 comments on commit 345c086

Please sign in to comment.