Reputation: 33
I have 500+ records in Users
table and I am showing list using following code in my Blade template.
In Controller
$users= Users::paginate(5);
In Blade view
$users->links();
This is showing pages from 1 to 10,
But I want to display first and last two pages from 1, 2 ....... 9,10
,
If user on page 5 pages should display like 3,4 ... 5... 9,10
Upvotes: 3
Views: 2464
Reputation: 12835
You can use the onEachSide() method
{{ $users->onEachSide(2)->links() }}
Laravel docs: https://laravel.com/docs/8.x/pagination#adjusting-the-pagination-link-window
Upvotes: 6