In this video we are going to learn about Livewire Pagination
So lets see how create pagination in livewire
First of lets create new component.
So switch to the command prompt and just run the command


php artisan make:livewire Users


Now run the application


php artisan serve


Now switch to the project and lets create the route for this component.
So just go inside the routes directory.
And then open web.php file.
Now just add here the route.
Route::get(‘/all-users’,Users::class);
Now just open Users.php component class file write the following code.


<?php

namespace App\\Http\\Livewire;

use App\\Models\\User;
use Livewire\\Component;
use Livewire\\WithPagination;

class Users extends Component
{
use WithPagination;
public function render()
{
$users = User::paginate(5);
return view('livewire.user-component',['users'=>$users]);
}
}


Save the file and now open users.blade.php view file.
And here create a table write the following code.


<div>
<div class=\"container\">
<div class=\"row\">
<div class=\"col-md-12\">
<div class=\"card\">
<div class=\"card-header\">
All Users
</div>
<div class=\"card-body\">
<table class=\"table table-striped\">
<thead>
    <tr>
        <th>Id</th>
        <th>Name</th>
        <th>Email</th>
    </tr>
</thead>
<tbody>
    @foreach ($users as $user)
        <tr>
            <td>{{$user->id}}</td>
            <td>{{$user->name}}</td>
            <td>{{$user->email}}</td>
        </tr>
    @endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>


For adding the pagination links after the closing table tag just write the following code.


{{$users->links()}}


One more thing add css for pagination.
<style>
nav svg{
height: 20px;
}
</style>
All done so lets check this.
So switch to the browser and just go to the url /all-users.
And here you can see the 5 records inside the table and this is pagination link.
So in this way we can create Livewire Pagination so that's all about Livewire Pagination.