2017 © Pedro Peláez
 

library laravel-item-paginate

Paginate based on last item, not pages.

image

askedio/laravel-item-paginate

Paginate based on last item, not pages.

  • Tuesday, August 30, 2016
  • by gcphost
  • Repository
  • 3 Watchers
  • 66 Stars
  • 3,961 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 3 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Laravel Item Paginator

Paginate based on last item, not page., (*1)

Build Status StyleCI Codacy Badge Codacy Badge, (*2)

Installation

composer require askedio/laravel-item-paginate

Add the following trait to your Models., (*3)

use \Askedio\ItemPaginator\ItemPaginatorTrait;

Add the following provider to config/app.php, (*4)

\Askedio\ItemPaginator\ItemPaginatorServiceProvider::class,

Usage

This package is based off simplePaginate and will take the same parameters., (*5)

$users = new User();

$paginated = $users->itemPaginate();

dd($paginated);

The last parameter is the field that will be used to paginate by, defaults to id., (*6)

itemPaginate($perPage = null, $columns = ['*'], $pageName = 'from', $from = 0, $field = null)

ORDER BY DESC

If you want to decend your sorting you'll want to use itemPaginateDesc instead of itemPaginate. The first page will add an extra query to find the last item., (*7)

Example Output

array:6 [
  "limit" => 2
  "next_page_url" => "http://localhost?from=190"
  "from" => 100
  "to" => 190
  "data" => array:2 [
    0 => array:8 [
      "id" => 100
      "name" => "test"
      "email" => "test@test.com"
      "password" => "test"
      "remember_token" => null
      "created_at" => "2016-08-02 18:13:19"
      "updated_at" => "2016-08-02 18:13:19"
      "deleted_at" => null
    ]
    1 => array:8 [
      "id" => 190
      "name" => "test2"
      "email" => "test2@test.com"
      "password" => "test"
      "remember_token" => null
      "created_at" => "2016-08-02 18:13:19"
      "updated_at" => "2016-08-02 18:13:19"
      "deleted_at" => null
    ]
  ]
]

Disclaimer

Will only sort by incremental ids.

I've only tested this with sqlite and mysql (see tests) so it may not work in every situation. Please report any you find., (*8)

The Versions

30/08 2016

dev-master

9999999-dev

Paginate based on last item, not pages.

  Sources   Download

MIT

The Requires

 

The Development Requires

30/08 2016

1.2.0

1.2.0.0

Paginate based on last item, not pages.

  Sources   Download

MIT

The Requires

 

The Development Requires

03/08 2016

dev-dev

dev-dev

Paginate based on last item, not pages.

  Sources   Download

MIT

The Requires

 

The Development Requires

03/08 2016

1.1.0

1.1.0.0

Paginate based on last item, not pages.

  Sources   Download

MIT

The Requires

 

The Development Requires

02/08 2016

1.0.2

1.0.2.0

Paginate based on last item, not pages.

  Sources   Download

MIT

The Requires

 

The Development Requires

02/08 2016

1.0.1

1.0.1.0

Paginate based on last item, not pages.

  Sources   Download

MIT

The Requires

 

The Development Requires

02/08 2016

1.0.0

1.0.0.0

Paginate based on last item, not pages.

  Sources   Download

MIT

The Requires

 

The Development Requires