PHPackages                             eastown/laravel-pagination - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. eastown/laravel-pagination

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

eastown/laravel-pagination
==========================

Pagination for laravel

1221PHPCI failing

Since Dec 22Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/eastown/laravel-pagination)[ Packagist](https://packagist.org/packages/eastown/laravel-pagination)[ RSS](/packages/eastown-laravel-pagination/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-pagination
==================

[](#laravel-pagination)

Pagination for laravel

Installation
------------

[](#installation)

```
composer require eastown/laravel-pagination
```

Example Models
--------------

[](#example-models)

`\App\User`

- id
- name
- score
- group\_id (group belongsTo `\App\UserGroup`)

`\App\UserGroup`

- id
- name

Usage
-----

[](#usage)

```
$pagination = (new Eastown\Pagination\Pagination(new \App\User()))
       ->setCurrentPage(1)
       ->setPageSize(20)
       ->conditions([
          new Condition('id', \Eastown\Pagination\Operator::GTE, 100),
          new Condition('id', \Eastown\Pagination\Operator::LTE, 10000),
      ])
      // Simple way
      // ->conditions([
      //          ['id', 'GTE', 100],
      //          ['id', 'LTE', 100],
      // ])
       ->selects([
           new \Eastown\Pagination\Select('SUM(score)', 'total_score'),
           new \Eastown\Pagination\Select('id'),
           new \Eastown\Pagination\Select('name'),
       ])
       // Simple way
       // ->selects([
       //   ['SUM(score)', 'total_score'],
       //   ['id'], // or just use string 'id',
       //   ['name']
       // ])
       ->groups([
           new \Eastown\Pagination\Group('id')
       ])
       // Simple way
       // ->groups([
       //   'id'
       // ])
       ->sorts([
            new \Eastown\Pagination\Sort('id', \Eastown\Pagination\Sort::SORT_DESC)
       ])
       // Simple way
      // ->sorts([
      //   ['id', 'desc']
      // ])
       ;

$total = $pagination->total();
$sum = $pagination->sum(['score']);
$data = $pagination->query();

// with page info
$info = $pagination->paginate();

// Output exp
// [
//    'data': [...],
//    'total': 100,
//    'page_size': 20,
//    'current_page': 1
// ]

// Map results
$info = $pagination->paginate(function($user){
    $user->token = uniqid();
    return $user;
});
```

Condition
---------

[](#condition)

```
(new Eastown\Pagination\Pagination(new \App\User()))
       ->setCurrentPage(1)
       ->setPageSize(20)
       ->conditions([
          new Condition('id', \Eastown\Pagination\Operator::GTE, 100),
          new Condition('id', \Eastown\Pagination\Operator::LTE, 10000),
          new Condition('id', \Eastown\Pagination\Operator::IN, [100, 101, 102]),
          new Condition('id', \Eastown\Pagination\Operator::NOT_IN, [201, 202, 203]),
          new Condition('name', \Eastown\Pagination\Operator::LIKE, '%aaa%'),
          new Condition('name', \Eastown\Pagination\Operator::NOT_LIKE, '%bbb%'),
          new Condition('score', \Eastown\Pagination\Operator::BETWEEN, [1, 100]),
          new Condition('score', \Eastown\Pagination\Operator::NOT_BETWEEN, [500, 1000]),
          new Condition('name', \Eastown\Pagination\Operator::REGEXP, '*'),
          new Condition('group', \Eastown\Pagination\Operator::HAS,
            [
                new Condition('name', \Eastown\Pagination\Operator::EQ, 'test_group')
            ]
          ),
          new Condition('group', \Eastown\Pagination\Operator::DOES_NOT_HAVE,
            [
              new Condition('name', \Eastown\Pagination\Operator::EQ, 'test_group2')
            ]
          )
      ])
      ->paginate();
```

Simple way

```
(new Eastown\Pagination\Pagination(new \App\User()))
       ->setCurrentPage(1)
       ->setPageSize(20)
       ->conditions([
            ['id', 'GTE', 100],
            ['id', 'LTE', 10000],
            ['id', 'IN', [100, 101, 102]],
            ['id', 'NOT_IN', [201, 202, 203]],
            ['name', 'LIKE', '%aaa%'],
            ['name', 'NOT_LIKE', '%bbb%'],
            ['score', 'BETWEEN', [1, 100]],
            ['score', 'NOT_BETWEEN', [500, 1000]],
            ['name', 'REGEXP', '*'],
            ['group', 'HAS',
                [
                    ['name', 'EQ', 'test_group']
                ]
            ],
            ['group', 'DOES_NOT_HAVE',
                [
                    ['name', 'EQ', 'test_group2']
                ]
            ],
      ])
      ->paginate();
```

Total
-----

[](#total)

```
(new Eastown\Pagination\Pagination(new \App\User()))->conditions(...)->total();

// Output exp
// 100
```

Sum
---

[](#sum)

```
(new Eastown\Pagination\Pagination(new \App\User()))->conditions(...)->sum(['field1', 'field2']);

// Output exp
// [
//     'field1': 100,
//     'field2': 200
// ]
```

Work with Request
-----------------

[](#work-with-request)

```
(new \Eastown\Pagination\RequestPagination(new \App\User()))->request($request)->paginate();
```

params can be passed by request

- current\_page
- page\_size
- conditions
- sorts
- selects
- groups
- sum\_fields

`http://example.com/?sorts[0][0]=id&sorts[0][1]=desc&sum_fields[0]=id&current_page=1&page_size=2&conditions[0][0]=name&conditions[0][1]=LIKE&conditions[0][2]=%3%`

`http://example.com/?sorts=[{"id":"desc"}]&sum_fields=["id"]&current_page=1&page_size=2&conditions=[["name","LIKE","%3%"]]`

`http://example.com/?sorts=[{"id":"desc"}]&sum_fields=["id"]&current_page=1&page_size=2&conditions={"name__like__":"%3%"}`

relationship usage:

`conditions={"group.name__like__":"%test%"}`

```
{
"data": [
        {
            "id": 3,
            "name": "123"
        },
        {
            "id": 2,
            "name": "223"
        }
    ],
    "total": 3,
    "page_size": 2,
    "current_page": 1,
    "request": {
        "conditions": [
            [
              "name", "LIKE", "%3%"
            ]
        ],
        "sorts": [
            [
              "id", "desc"
            ]
        ],
        "sum_fields": [
          "id"
        ],
        "page_size": "2",
        "current_page": "1"
    },
    "sum": {
      "id": 6
    }
}
```

> > You can extend Pagination to make your own RequestPagination to handle request by the way you like

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance47

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5058780?v=4)[eastown](/maintainers/eastown)[@eastown](https://github.com/eastown)

---

Top Contributors

[![eastown](https://avatars.githubusercontent.com/u/5058780?v=4)](https://github.com/eastown "eastown (15 commits)")

### Embed Badge

![Health badge](/badges/eastown-laravel-pagination/health.svg)

```
[![Health](https://phpackages.com/badges/eastown-laravel-pagination/health.svg)](https://phpackages.com/packages/eastown-laravel-pagination)
```

###  Alternatives

[mcguffin/acf-quick-edit-fields

WordPress Plugin implementing Column Displaying, QuickEdit and BulkEdit for Advanced Custom Fields (ACF)

36461.6k](/packages/mcguffin-acf-quick-edit-fields)[a6digital/laravel-default-profile-image

Laravel package to create default profile image using name of user.

41350.1k](/packages/a6digital-laravel-default-profile-image)[konekt/address

Laravel module for handling countries, cities, addresses, people and organizations

18246.8k25](/packages/konekt-address)[danielme85/laravel-geoip2

Service provider and DB downloader for Maxminds PHP API GeoIP2.

15177.8k](/packages/danielme85-laravel-geoip2)[robloach/jquery-once

Act on jQuery elements only once.

592.5k](/packages/robloach-jquery-once)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
