2017 © Pedro Peláez
 

library laravel-linkheader-paginator

Laravel Paginator that moves pagination info to the HTTP LinkHeader

image

danbovey/laravel-linkheader-paginator

Laravel Paginator that moves pagination info to the HTTP LinkHeader

  • Tuesday, November 8, 2016
  • by danbovey
  • Repository
  • 1 Watchers
  • 1 Stars
  • 154 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Laravel LinkHeader Paginator

Travis Packagist Downloads Version License, (*1)

A custom Laravel/Lumen Paginator that uses the Link header (RFC 5988) to send pagination info in the response. Removes the envelope around data!, (*2)

Adds a method called toResponse that returns a JSON response with headers. The getHeaders method exists if you need different response data., (*3)

Installation

$ composer require danbovey/laravel-linkheader-paginator

Usage

Create the pagination with the Eloquent/DB Builder and pass it to the LengthAwarePaginator., (*4)

$items = User::where('active', 1)->paginate(20);

$paginator = new LengthAwarePaginator($items);

return $paginator->toResponse();

"Simple Pagination", (*5)

The simple paginator does not need to know the total number of items in the result set; however, because of this, the class does not return the URI of the last page. Ironically, the simple paginator is more work using this library. To save on queries you should skip using the methodsimplePaginate, and implement the skip/take logic yourself., (*6)

$page = $request->get('page');
$perPage = 20;
// Take one more than needed to see if there is a next page
$users = User::skip(($page - 1) * $perPage)
    ->take($perPage + 1);

$paginator = new Paginator($simple, $items);

return $paginator->toResponse();

The Versions

08/11 2016

dev-master

9999999-dev https://github.com/danbovey/laravel-linkheader-paginator

Laravel Paginator that moves pagination info to the HTTP LinkHeader

  Sources   Download

MIT

The Development Requires

by Dan Bovey

laravel pagination paginator linkheader

07/11 2016

1.0.1

1.0.1.0 https://github.com/danbovey/laravel-linkheader-paginator

Laravel Paginator that moves pagination info to the HTTP LinkHeader

  Sources   Download

MIT

The Development Requires

by Dan Bovey

laravel pagination paginator linkheader

06/11 2016

1.0.0

1.0.0.0 https://github.com/danbovey/laravel-linkheader-paginator

Laravel Paginator that moves pagination info to the HTTP LinkHeader

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dan Bovey

laravel pagination paginator linkheader