Skip to content

Commit 66c5afc

Browse files
authored
Fix cursor pagination with HasManyThrough (#40300)
1 parent be0c772 commit 66c5afc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,22 @@ public function simplePaginate($perPage = null, $columns = ['*'], $pageName = 'p
431431
return $this->query->simplePaginate($perPage, $columns, $pageName, $page);
432432
}
433433

434+
/**
435+
* Paginate the given query into a cursor paginator.
436+
*
437+
* @param int|null $perPage
438+
* @param array $columns
439+
* @param string $cursorName
440+
* @param string|null $cursor
441+
* @return \Illuminate\Contracts\Pagination\CursorPaginator
442+
*/
443+
public function cursorPaginate($perPage = null, $columns = ['*'], $cursorName = 'cursor', $cursor = null)
444+
{
445+
$this->query->addSelect($this->shouldSelect($columns));
446+
447+
return $this->query->cursorPaginate($perPage, $columns, $cursorName, $cursor);
448+
}
449+
434450
/**
435451
* Set the select clause for the relation query.
436452
*

0 commit comments

Comments
 (0)