Laravel Pagination

Laravel Pagination

Basic Usage

Displaying Pagination Results

<div class="container">
    @foreach ($users as $user)
        {{ $user->name }}
    @endforeach
</div>

{{ $users->links() }}

Customizing The Pagination View

{{ $paginator->links('view.name') }}

// Passing data to the view...
{{ $paginator->links('view.name', ['foo' => 'bar']) }}
Php artisan vendor:publish --tag=laravel-pagination
Use Illuminate\Pagination\Paginator;

public function boot()
{
    Paginator::defaultView('pagination::view');

    Paginator::defaultSimpleView('pagination::view');
}

Paginator Instance Methods

  • $results->count().
  • $results->currentPage().
  • $results->firstItem().
  • $results->hasMorePages().
  • $results->lastItem().
  • $results->lastPage() (Not available when using simplePaginate).
  • $results->nextPageUrl().
  • $results->onFirstPage().
  • $results->perPage().
  • $results->previousPageUrl().
  • $results->total() (Not available when using simplePaginate).
  • $results->url($page).

Laravel Pagination — Structure map

Clickable & Draggable!

Laravel Pagination — Related pages: