Laravel Pagination

August 20, 2017

Controller

UserController.php



View

users.blade.php

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">Users</div>
                <div class="panel-body">

                    <table class="table table-hover table-striped">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>Name</th>
                        <th>Email</th>
                    </tr>
                    </thead>

                    <tbody>
                    @foreach ($users as $user)
                    <tr>
                        <td>{{ $user->id }}</td>
                        <td>{{ $user->name }}</td>
                        <td>{{ $user->email }}</td>
                    </tr>
                    @endforeach
                    </tbody>
                    </table>

                    {{ $users->links() }}
                    
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

Route


    Route::get('users', 'UserController@users');


Related sections in Laravel Documentation:

• Simple Pagination
• Custom Pagination
• Append parameters to generated links