Laravel Pagination Get First Page Example

Admin   Laravel   479  2021-03-13 23:40:04

Hi Guys,

In this example,I will learn you how to get first page pagination can easy and simply Pagination first Button in laravel.

we can add first link on pagination using simplePaginate() in laravel 6, laravel 7 and laravel 8 application. laravel provide new eloquent method simplePaginate() for adding simple pagination with only first button link.

Create Route:

In first step, we will create simple routes for getting users and view it, so let's add new route in web.php file:



Route::get('users', '[email protected]');

Create Controller:

Now, we will create new UserController with index() method. in index() we will write simple pagination code. so let's create as like bellow:




namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\User;

class UserController extends Controller



* The attributes that are mass assignable.


* @var array


public function index()


$users = User::paginate(10)->onFirstPage();

return view('users', compact('users'));



Create View File:

In this last step, we will create simple blade file and display users with pagination. so let's add bellow code:



<!DOCTYPE html>



<title>Laravel Next Previous Link Button Pagination -</title>

<link rel="stylesheet" href="" target="_blank" rel="nofollow" >



<div class="container">

<h1>Laravel Pagination Get First Page Example -</h1>

<table class="table table-bordered">





@foreach($users as $user)


<td>{{ $user->id }}</td>

<td>{{ $user->name }}</td>




{{ $users->links() }}




It will help you...