Laravel Pagination Get First Page Tutorial

Laravel 8 , Laravel 7



Laravel Pagination Get First Page Tutorial

Hi guys, Today i will explained to the Laravel Pagination Get First Page Tutorial in your laravel 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.

The Laravel Pagination Get First Page is so easy to you can just follow my step by step and learn Laravel Pagination Get First Page Tutorial.

So let's start to the example and follow to the my all step.



Step 1: Create a User Controller

Next you can require to the User Controller so create a User Controller in just following command through.



namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Models\User;

class UserController extends Controller



* The attributes that are mass assignable.


* @var array


public function index(Request $request)


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

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



Step 2: Add Blade File

Last step to create a users.blade.php file and use this code.


<!DOCTYPE html>



<title>Laravel Pagination Get First Page Tutorial</title>

<link rel="stylesheet" href="">



<div class="container">

<h1>Laravel Pagination Get First Page Tutorial</h1>

<table class="table table-bordered">





@foreach($users as $user)


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

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




{{ $users->links() }}




Step 3: Create Route

Last step to create a route in web.php file and use this code.


use Illuminate\Support\Facades\Route;

use App\Http\Controllers\UserController;



| Web Routes



| Here is where you can register web routes for your application. These

| routes are loaded by the RouteServiceProvider within a group which

| contains the "web" middleware group. Now create something great!



Route::get('users', [UserController::class, 'index'])->name('users');

Ok, now you have to create some dummy records on users table.

So, finally we are done with our code we can get below output.

php artisan serve

Browser url run : http://localhost:8000/users