Laravel Pagination Get Per Page Example




Laravel Pagination Get Per Page Example

Laravel Pagination Get Per Page Example

Hi guys,Today i will explained to the the Laravel Pagination Get Per Page Example in your laravel project.the laravel pagination is so easy to you can just follow my step by step and learn Laravel Pagination Get Per Page Example.

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


Count : {{ $users->perPage() }}

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()


$users = User::paginate(10);

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 previous page</title>

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



<div class="container">

<h1>laravel pagination get previous page</h1>

<h4>Count : {{ $users->perPage() }}</h4>

<table class="table table-bordered">





@foreach($users as $user)


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

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




<ul class="pagination">

<li class="page-item"><a class="page-link" href="{{ $users->nextPageUrl() }}">Next</a></li>

<li class="page-item"><a class="page-link" href="{{ $users->previousPageUrl() }}">Previous</a></li>





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


#Laravel 8

#Laravel 7