PHPackages                             flagstudio/laravel-paginate - 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. flagstudio/laravel-paginate

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

flagstudio/laravel-paginate
===========================

Different paginate macros for laravel eloquent builder and collection

v0.1.3(4y ago)157.9k↓50%2[1 issues](https://github.com/Flagstudio/laravel-paginate/issues)MITPHPPHP ^7.2|^8.0CI failing

Since Apr 24Pushed 4y ago2 watchersCompare

[ Source](https://github.com/Flagstudio/laravel-paginate)[ Packagist](https://packagist.org/packages/flagstudio/laravel-paginate)[ RSS](/packages/flagstudio-laravel-paginate/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

Set of Laravel Builder and Collection macros for pagination
===========================================================

[](#set-of-laravel-builder-and-collection-macros-for-pagination)

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

[](#installation)

You can pull in the package via composer:

```
composer require flagstudio/laravel-paginate
```

The package will automatically register itself.

Macros
------

[](#macros)

These macros are used for Eloquent Builder and Collection. The main difference in using pagination on a collection or builder is that builder has not yet perform the database request, i.e. paginate will perform request to get needed amount of records from database. Collection already have all elements and paginate will not perform any database requests.

- [`paginate`](#paginate)
- [`paginateFirstDifferent`](#paginateFirstDifferent)
- [`paginateWithPrevious`](#paginateFirstDifferent)

### `paginate`

[](#paginate)

Create a `LengthAwarePaginator` instance from Builder or Collection.

```
collect($posts)->paginate(5); // From Collection instance
Post::orderBy('created_at', 'desc')->get()->paginate(5); // From Collection instance
Post::orderBy('created_at', 'desc')->paginate(5); // From Builder instance
```

This paginates the contents of `$posts` with 5 items per page. `paginate` accept some options, head over to [the Laravel docs](https://laravel.com/docs/7.x/pagination) for an in-depth guide.

### `paginateFirstDifferent`

[](#paginatefirstdifferent)

Create a `FirstDifferentLengthAwarePaginator.php` instance which extend `LengthAwarePaginator` from Builder or Collection.

```
collect($posts)->paginateFirstDifferent(10, 5); // From Collection instance
Post::orderBy('created_at', 'desc')->get()->paginateFirstDifferent(10, 5); // From Collection instance
Post::orderBy('created_at', 'desc')->paginateFirstDifferent(10, 5); // From Builder instance
```

This paginates the contents of `$posts` with 10 items at first page and 5 items for next pages. `paginateFirstDifferent` accepts same options as [`paginate`](#paginate) but instead of `$perPage` accepts two parameters `$firstPerPage` and `$nextPerPage`

You can also pass third parameter to get all post from first to current page.

```
Post::orderBy('created_at', 'desc')->paginateFirstDifferent(10, 5, true);
```

### `paginateWithPrevious`

[](#paginatewithprevious)

Create a `LengthAwarePaginator` instance from Builder or Collection.

```
collect($posts)->paginateWithPrevious(5); // From Collection instance
Post::orderBy('created_at', 'desc')->get()->paginateWithPrevious(5); // From Builder instance
Post::orderBy('created_at', 'desc')->paginateWithPrevious(5); // From Builder instance
```

This paginates the contents of `$posts` with 5 items per page but takes all posts from first to current page. At example if current page equals 5 then `paginateWithPrevious` will return 25 posts (5 per each page). It useful if you want load all posts for current page after reloading page or share link with pagination (). `paginateWithPrevious` accepts same options as [`paginate`](#paginate)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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.

###  Release Activity

Cadence

Every ~193 days

Total

4

Last Release

1636d ago

PHP version history (2 changes)v0.1.0PHP ^7.2

v0.1.3PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/12d17ea2c22cc2f91d54aed0b98914b5435925122f85905eba11f2a8b46d6f15?d=identicon)[flagstudio](/maintainers/flagstudio)

---

Top Contributors

[![vasishakd](https://avatars.githubusercontent.com/u/19591425?v=4)](https://github.com/vasishakd "vasishakd (3 commits)")[![VKuksovskii](https://avatars.githubusercontent.com/u/22526327?v=4)](https://github.com/VKuksovskii "VKuksovskii (1 commits)")

---

Tags

laravel-builder-macroslaravel-builder-paginatelaravel-collection-paginatelaravel-paginatelaravel-paginationlaravel-paginatorlarvel-collection-macroslaravel-collection-macroslaravel-builder-macroslaravel-collection-paginatepaginate-collectionlaravel-paginate-collectionflagstudiolaravel-paginate-macroslaravel-paginate-builder

### Embed Badge

![Health badge](/badges/flagstudio-laravel-paginate/health.svg)

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

###  Alternatives

[spatie/laravel-collection-macros

A set of useful Laravel collection macros

1.9k5.7M29](/packages/spatie-laravel-collection-macros)[wireui/wireui

TallStack components

1.8k1.3M16](/packages/wireui-wireui)[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4205.3M84](/packages/livewire-volt)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21147.4k](/packages/ramonrietdijk-livewire-tables)

PHPackages © 2026

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