How to do Pagination in Laravel 8 with Bootstrap
2021-11-01T04:57:33 - Vicky Chhetri
Read Time:45 Second
This blog is only for those who know laravel basics, if you don’t know than this is not beneficial for you. you can still read below lines for general knowledge.
In this tutorial, I will share how to create simple pagination in the Laravel 8 application. We will learn to construct simple pagination in laravel 8 application.
Keyword
pagination
- paginate()
2. links()
These two keyword is only required to do pagination in laravel.
cd laravel-page-project
2021
Write your code for the routes, controller, model to handle pages or list. we will directly continue to the section where we are going to use pagination.
public function getPageData(){
$data = Pages::all();
return view('home')
->with('data',$data);
}
Replace above code with
public function getPageData(){
$data = Pages::paginate(10);
return view('home')
->with('data',$data);
}
HTML FILE or View
Section where you want to show pagination write below code.
{!! $data->links() !!}