Laravel 5.7 - Pagination Link Customizations Example

Admin   PHP   55  2020-08-08 05:43:11

Today, i will guide you how to customize pagination link in laravel 5.7. Laravel 5.7 has a new pagination method to customize the number of links on each side of the current page link.

Laravel release 5.7 new version with lot's of new features. One of the new feature is a Pagination Link Customizations from them. laravel provide onEachSide() helper to make customize page link. You don't require to create custom pagination view for link customize.

Here i will quick show you how it is work with linksOnEachSide. we also create simple example so you can understand how it should work.

Example 1: Current Page 7

{{ $users->onEachSide(1)->links() }}

//Output

1 2 .. 6 7 8 .. 25 26

Example 2: Current Page 7

{{ $users->onEachSide(2)->links() }}

//Output

1 2 .. 5 6 7 8 9 .. 25 26

Example 3: Current Page 7

{{ $users->onEachSide(3)->links() }}

//Output

1 2 .. 4 5 6 7 8 9 10 .. 25 26

Preview:

Content Overview

Step 1 : Install Laravel 5.7

Step 2: Create Dummy Records

Step 3: Create Route

Step 4: Create SearchController

Step 5: Create View File