In this video we are going to learn about Livewire Search With Pagination.
So lets see how can create search with pagination.
In previous video we have create this livewire crud.
Now lets add search box inside this.
So for that just go inside the students.blade.php view file.
And here inside the card header just add.
A input text field for serach input text.

Now go to the Students.php component class file.
And here lets create a property.


public $searchTerm;


Now inside the render method write the following code.


public function render()
{
$search = '%' . $this->searchTerm. '%';
$students = Student::where('firstname','LIKE',$search)
->orWhere('lastname','LIKE',$search)
->orWhere('email','LIKE',$search)
->orWhere('phone','LIKE',$search)
->orderBy('id','DESC')->paginate(5);
return view('livewire.students',['students'=>$students]);
}


also import the WithPagination and use inside the class so write the following code.

Before class add the following code.

use Livewire\\WithPagination;


Now inside the class just use this so write as following inside the class.


use WithPagination;


Now Go to the students.blad.php file add the pagination link.
So after the table just write the following code.


{{$students->links()}}


Now add a css inside the section just write the following css.


<style>
nav svg{
max-height:20px;
}
</style>



Now save all files and lets check it.
So switch to the browser and just refresh the page
And here you can see the search field.
Now just enter any text here.
You can see it works and also you can see the paginate links.
So in this way we can create Livewire Search With Pagination.