Laravel 5.7 – Pagination Link Customizations Example

Laravel 5.7 – Pagination Link Customizations Example

In this post we will give you information about Laravel 5.7 – Pagination Link Customizations Example. Hear we will give you detail about Laravel 5.7 – Pagination Link Customizations ExampleAnd how to use it also give you demo for it if it is necessary.

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() }}


1 2 .. 6 7 8 .. 25 26

Example 2: Current Page 7

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


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

Example 3: Current Page 7

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


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


Step 1: Install Laravel 5.7

first of all we need to get fresh Laravel 5.7 version application using bellow command, So open your terminal OR command prompt and run bellow command:

composer create-project --prefer-dist laravel/laravel blog

Step 2: Create Dummy Records

In this step, we require to run migration first. So after successfully run migration you have users table, so let’s run bellow command:

php artisan migrate

Now we need to add some dummy records on users table using laravel factory, so we can basically check it properly how it works.

php artisan tinker

>>> factory(AppUser::class, 100)->create();

Step 3: Create Route

In this is step we need to create one route for listing page. so open your “routes/web.php” file and add following route.


Route::get('pagination', 'PaginationController@index');

Step 4: Create PaginationController

In this step, we have to create new controller as PaginationController and we have also need to one methos index() on that controller like as you can see bellow:



namespace AppHttpControllers;

use IlluminateHttpRequest;

use AppUser;

class PaginationController extends Controller



* Display a listing of the resource.


* @return IlluminateHttpResponse


public function index()


$users = User::paginate(5);

return view('users', compact('users'));



Step 5: Create View File

In Last step, let’s create users.blade.php(resources/views/users.blade.php) for layout and lists all users code here and put following code:


<!DOCTYPE html>



<title>Laravel 5.7 - Pagination Link Customizations -</title>

<link rel="stylesheet" href="" />



<div >

<h1>Laravel 5.7 - Pagination Link Customizations -</h1>

<table >






@foreach($users as $user)


<td>{{ $user->id }}</td>

<td>{{ $user->name }}</td>

<td>{{ $user->email }}</td>




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




Now we are ready to run our example so run bellow command for quick run:

php artisan serve

Now you can open bellow URL on your browser:

Also see:Laravel 5.7 Autocomplete Search from Database using Typeahead JS


I hope it can help you…

Hope this code and post will helped you for implement Laravel 5.7 – Pagination Link Customizations Example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

5  +  2  =  

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US