Up until now, when you’re working with Laravel’s paginator and if you wanted to check whether the user is on the first page of the pagination in a Blade file, you would be using the onFirstPage() method like so. But when you want to check if the user is on the last page, there isn’t a straightforward method to do so.

That’s slightly odd since you’re not using a method that doesn’t sound like its intended purpose and you’re kind of reversing the logic.

The onLastPage method https://github.com/laravel/framework/pull/40265 now introduces a new onLastPage() method that lets you check if the user is on the last page of the pagination like so. As you can tell, this method sounds exactly like what you’re intending to do and it’s more consistent with the other method onFirstPage().
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners