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() !!}
About Post Author
Vicky Chhetri
About Author
Vicky Chhetri
Responsible for website’s coding, design and layout. This includes building website from concept all the way to completion from the bottom up. It might also include responsibility for the server side of web applications.