Laravel 7 Pagination Curd With Example

This is a short guide on pagination in laravel 7. Here you will learn laravel 7 pagination example blade. In this article, we will implement a laravel 7 pagination example code. This tutorial will give you simple example of laravel 7 pagination example. follow bellow step for engender pagination in laravel 7 example.

We ken pagination is a primary requisite of each and every project. so if you are neophyte with laravel than you must ken how to utilize pagination in laravel 7 and what is other function that can utilize with laravel 7 pagination.

In this example i will explicate you from scratch how to working with laravel pagination. so let’s follow bellow tutorial for engendering simple example of pagination with laravel 7.

Step 1: Add Route

First thing is we put one route in one for list users with pagination. So simple add both routes in your route file.


Route::get('users', 'UserController@index');

Step 2: make Controller

Same things as above for route, here we will add one new method for route. index() will return users with pagination data, so let’s add bellow:


namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
class UserController extends Controller
     * Display a listing of the resource.
     * @return \Illuminate\Http\Response
    public function index()
        $data = User::paginate(10);
        return view('users',compact('data'));

Step 3: Create Blade File

In this step, you require to engender users blade file and put bellow code with links() so it will engender pagination automatically. So let’s put it.

<table class="table table-bordered">
            <th width="300px;">Action</th>
        @if(!empty($data) && $data->count())
            @foreach($data as $key => $value)
                    <td>{{ $value->name }}</td>
                        <button class="btn btn-danger">Delete</button>
                <td colspan="10">There are no data.</td>
{!! $data->links() !!}

Pagination with appends parameter

{!! $data->appends(['sort' => 'votes'])->links() !!}

Pagination with appends request all parameters

{!! $data->appends(Request::all())->links() !!}

About OakML

Hi we are enthusiastic developers team, we try to serve some good idea to open source community

Leave a Reply

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

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!