How to Get First Page Last Page Total Page in Laravel Pagination

Hello Artisan,

In this example i will show you that how we can get first page from laravel pagination. I also show you that how to show get last page, total page from laravel pagination. If you don't know how to do that then this example is for you.

Sometimes we need to show first page, sometimes need last page, total page etc. In this tutorial you will know how we can show that. I will share souce code with you so that you can create it and use it.

First Page:

$users = User::paginate(10)->onFirstPage();

 

Last Page:

$users = User::paginate(10)->lastPage();

 

Total Page:

$users = User::paginate(10)->total();

 

Hope it can help you.

 

Facebook Github
A web enthusiastic, a self-motivated full-stack software engineer from Dhaka, Bangladesh with experience in developing applications using Laravel , React and Vue js