
Laravel 5.7: New Pagination Link Customizations
Laravel 5.7 has a new pagination method to customize the number of links on each side of the paginator. Thanks to the new method you no longer need a custom pagination view in some cases. Here’s the API you can use to define the link count on each side of the current page:
<?php
User::paginate(10)->onEachSide(5);
Thanks to Michał Putkowski for the contribution, you should check it out to see the implementation. Here’s another visual of what you can expect with this feature, presented by Rachid Laasri:
A cool new @laravelphp 5.7 feature:
You can customize the number of pages to show on each side of the current page without having to extend the pagination view. ???? pic.twitter.com/P7ywcbqhHQ
— Rachid Laasri (@RashidLaasri) August 21, 2018
This new feature will be excellent to cut out the need for a custom template in some cases, but it’s still useful to know how to customize the pagination view.
Editors Note: At the time of writing the method was linksOnEachSide
but it was later changed to onEachSide
Filed in: Laravel 5.7
Enjoy this? Get Laravel News delivered straight to your inbox every Sunday.
No Spam, ever. We'll never share your email address and you can opt out at any time.
Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.
Laravel Jobs

- Senior Laravel Engineer
-
Remote okay (must already live in USA)
Hawthorne Effect - Senior Software Engineer (Remote - Contract)
-
Remote
Koodi Systems - PHP Developer
-
Pittsburgh / Remote
Sequoia Waste Solutions - Software Developer
-
Eindhoven
Simac IDS - Application Developer Level II (CakePHP / MySql / Vue.js)
-
Lancaster, PA
Harbor Compliance - FULL STACK LARAVEL DEVELOPER
-
LONDON - WEST END
AMPERSAND HEATLH - Mid/Senior Laravel Developer - U.S. Developers Only
-
Kenner, Louisiana
Profit Miner Technologies