[8.x] Add onLastPage method to the Paginator #40265
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In short:
This PR adds a convenience method to the paginator to determine if we are on the last page.
Why:
There is a useful
onFirstPage
method but it lacks the oppositeonLastPage
method.I was just writing some blade code for a Tailwind pagination component and without reading a any documentation
onFirstPage
worked.Meaning, you can have the following code:
But for the last page, you need to call an unexpected
hasMorePages
method and reverse the logic, so it becomes:So not only did I encounter a blade error, because
onLastPage
did not exist, but also I had to reverse the logic.This PR keeps things consistent by adding a
onLastPage()
so you can simple do:Which, in my mind, is a very logical thing to try after using
onFirstPage
without reading any documentation.