Laravel pagination

Friends, many times what happens is that there is a lot of data in our return database table, meaning it is in thousands and lakhs and when we bring it in our website or printing in a format, then it increases a lot.

To solve this problem, many languages ​​like Laravel or HP have developed a method with the help of which we can display 10 or 15 answers as many as we set in a page and for the rest of the data we create a page and to reach this page we create a page like a vacation which we denoted by number.

 

 

To create a presentation in Laravel we will use the below steps:

Controller:

function car_details(Request $req, $id){
   $data = DB::table('car_comparision')->paginate(10);
   return view('admin/carcomparision.all_cars', ['data' => $data]);
}
View:

<div class="container">
  @foreach ($usersas$user)
    {{$user->name}}
  @endforeach
</div>

<div class="d-flex">
  {{ $data->links() }}
</div>
// Directly in your blade file
$data->links('pagination::bootstrap-4')

 

 

 

Leave a Reply