How to do Pagination in Laravel 8 with Bootstrap

Laravel Paination
0 0
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
  1. 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

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.
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

About Author

By 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.

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

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