Skip to content

[8.x] Handle cursor paginator when no items are found#42963

Merged
taylorotwell merged 2 commits intolaravel:8.xfrom
rodrigopedra:issue-42962
Jun 27, 2022
Merged

[8.x] Handle cursor paginator when no items are found#42963
taylorotwell merged 2 commits intolaravel:8.xfrom
rodrigopedra:issue-42962

Conversation

@rodrigopedra
Copy link
Copy Markdown
Contributor

Closes #42962

As noted by issue #42962, if the user has a link to a next, or previous page from a pagination using cursor pagination, accessing this URL throws an exception when no items are found.

This PR:

  • Modifies AbstractCursorPaginator@previousCursor and AbstractCursorPaginator@nextCursor methods to check if the $items collection is empty, and if so early returning null before trying to build their respective Cursor instances
  • Add a test case that would fail without the this PR's proposed changes

@driesvints driesvints linked an issue Jun 27, 2022 that may be closed by this pull request
@taylorotwell taylorotwell merged commit b266b75 into laravel:8.x Jun 27, 2022
@rodrigopedra rodrigopedra deleted the issue-42962 branch June 27, 2022 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cursor pagination fails if records have been deleted

2 participants