Laravel 8.x Custom Pagination Example Tutorial

Hello Artisan 

In this tutorial i will discuss about Laravel pagination example. In this tutorial I am going to tell you how to building and apply new custom paginator view in Laravel 8 application. Laravel 5.3 added new features and update for easily customize your own manual pagination blade template.

By default Laravel provide very simple pagination. But in this tutorial we will create our own custom pagination. But if you are not using bootstrap pagination and you want to customize then you can simply change OR if you want to add new bootstrap pagination layout then you can follow this laravel custom pagination tutorial.

I will simple create some dummy users and then using those users i will show our custom pagination page. I will use laravel custom pagination template to do this custom pagination in laravel 8. See below pic to know what we are going to make.




Step 1: CreatePagination Template

As we are going to use laravel custom pagination template, that's why run below command to have it.

php artisan vendor:publish --tag=laravel-pagination


After running above command run you will get new folder "pagination" on views files(resources/views/vendor). In pagination folder you will get following files by default:

  • default.blade.php
  • bootstrap-4.blade.php
  • simple-bootstrap-4.blade.php
  • simple-default.blade.php
  • semantic-ui.blade.php 


But we are going to use our own custom pagination template. We don't use any of the above template. 


Step 2: Add Route

Now we need routes to see our pagination page. So create this below route and create some dummy data of users.


Route::get('/', 'TestController@index');


Read also :  Laravel 7.x Ajax Pagination with Next And Previous Button


Step 3: Add Controller 

Ok, now we have to add new controller method "index()" in your TestController, so if you haven't created TestController then you can create it and paste this following code.


namespace App\Http\Controllers;

use Illuminate\Http\Request;

class TestController extends Controller
    public function index()
    	$users = \App\User::paginate(7);
        return view('welcome',compact('users'));


Step 4: Create Blade File 

Now we need to create our blade file for users view and custom pagination template. So create it with the following path.



Read also : Laravel 7.x Infinite Scroll (Load More) Example Tutorial


At last we have to create welcome.blade.php file and we will use our custom pagination template. So let's create welcome page and put bellow code on it.



Read also : Create Custom Pagination with Pretty URL in Laravel


Hope this laravel custom pagination tutorial will help you.


#laravel #laravel-7 #laravel-7x #custom #pagination #paging