In this laravel tutorial, we will discuss two types of pagination method paginate vs simple paginate in laravel 6, laravel 7 and laravel 8.
Laravel paginate vs simple paginate method.
Laravel provide two types of pagination method first is paginate method which is useful when we require next previous button and page links or we also customize our pagination links.
Second pagination method is simple paginate method which is only provide next and previous links. When we require only the next and previous buttons then simplePaginate method is enough.
The only difference between paginate vs simplePaginate method is paginate method contains more data show it takes more time in execution compare to simplePaginate, so paginate method use when requiring page links. Let an example of both types of pagination methods.
StudentController
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; class StudentController extends Controller{ public function index(){ //pagination method $students = DB::table('students')->paginate(10); //OR //simple pagination $students = DB::table('students')->simplePaginate(10); return view('students', compact('students')); } }
View File students.blade.php
@foreach($students as $student) <p>{{ $student->id }} : {{ $student->name }}</p> @endforeach {{ $students->links() }}
You read this tutorial on advanced web tutorial. here we provide beginners to advanced tutorial.
Anmol Sharma
I am a software engineer and have experience in web development technologies like php, Laravel, Codeigniter, javascript, jquery, bootstrap and I like to share my deep knowledge by these blogs.
Related tutorial links
- laravel query builder introduction tutorial
- part 1 laravel query insert data
- part 2 laravel all type of where conditions in query builder
- part 3 laravel whereDate, whereYear and whereTime qyery method
- part 4 compare two db columns in laravel query builder
- part 6 laravel pluck method get single column value
- part 7 laravel select and addselect query in query builder
- part 5 laravel first and find queries
- part 8 laravel edit and update method query explaination
- Part 9 laravel query for update or insert data by one method
- part 10 laravel delete vs truncate vs drop method
- part 11 gropupby and orderby query tutorial
- Part 12 laravel union of two queries
- part 13 laravel all aggregate functions with example
- part 14 laravel query builder chunk method
- part 15 laravel exists() and doesntExist() method
- part 16 laravel paginate vs simplePaginate method
- part 17 laravel all join methods