PHPackages                             aneeskhan47/laravel-pagination-merge - 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. aneeskhan47/laravel-pagination-merge

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

aneeskhan47/laravel-pagination-merge
====================================

Merge multiple laravel paginate instances

v1.0.7(1y ago)1823.4k↓37.5%3MITPHPPHP ^7.2|^8.0|^8.1|^8.2CI passing

Since Jun 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/aneeskhan47/laravel-pagination-merge)[ Packagist](https://packagist.org/packages/aneeskhan47/laravel-pagination-merge)[ Docs](https://github.com/aneeskhan47/laravel-pagination-merge)[ Fund](https://www.paypal.com/paypalme/aneeskhan47)[ RSS](/packages/aneeskhan47-laravel-pagination-merge/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (5)Versions (9)Used By (0)

[![](https://camo.githubusercontent.com/9413abdae00c00a7573c4b833c9ad065a2966f129a405f4a0c16aff588dd41b0/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c253230506167696e6174696f6e2532304d657267652e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d616e6565736b68616e34372532466c61726176656c2d706167696e6174696f6e2d6d65726765267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d4d657267652b6d756c7469706c652b6c61726176656c2b706167696e6174652b696e7374616e636573266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)](https://camo.githubusercontent.com/9413abdae00c00a7573c4b833c9ad065a2966f129a405f4a0c16aff588dd41b0/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c253230506167696e6174696f6e2532304d657267652e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d616e6565736b68616e34372532466c61726176656c2d706167696e6174696f6e2d6d65726765267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d4d657267652b6d756c7469706c652b6c61726176656c2b706167696e6174652b696e7374616e636573266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)

Pagination Merge for Laravel 5/6/7/8/9/10/11/12
===============================================

[](#pagination-merge-for-laravel-56789101112)

[![Latest Version on Packagist](https://camo.githubusercontent.com/63a977ddabe1629239eb45ff57c01ba80c6b2336549a27ebb658217326bb7f9b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e6565736b68616e34372f6c61726176656c2d706167696e6174696f6e2d6d657267652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aneeskhan47/laravel-pagination-merge)[![Total Downloads](https://camo.githubusercontent.com/01855262737781b2cf2df8772d8b1a420bdb285098535faffd7f014f4c0caae7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616e6565736b68616e34372f6c61726176656c2d706167696e6174696f6e2d6d657267652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aneeskhan47/laravel-pagination-merge)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/7be77084406cd085745806d898b120171981039a32552cb56d7aaa2106810f7d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616e6565736b68616e34372f6c61726176656c2d706167696e6174696f6e2d6d657267652f7068702d63732d66697865722e796d6c3f6c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/aneeskhan47/laravel-pagination-merge/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)![Laravel Versions](https://camo.githubusercontent.com/1d8a5f774f2e7b7161f4b436c050d1d412a8ef038add6ff4461d1c6f66a4a970/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d352e78253243253230362e78253243253230372e78253243253230382e78253243253230392e7825324325323031302e7825324325323031312e7825323031322e782d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)

A simple Laravel pagination merge package that allows you to merge multiple `->paginate()` instances.

### Some Background

[](#some-background)

I had to deal with something like that in a project I was working on, where in one of the pages I had to display two types of publication paginated and sorted by the created\_at field. In my case, it was a **Post** model and an **Event** Model (hereinafter referred to as publications).

The only difference is I didn't want to get all the publications from the database and then merge and sort the results, as you can imagine it would rise a performance issue if we have hundreds of publications.

So I figure out that it would be more convenient to paginate each model and only then, merge and sort them. that's why I built this package.

This package is heavily inspired by this stackoverflow [answer](https://stackoverflow.com/a/58252907)

⚡️ Installation
---------------

[](#️-installation)

### For Laravel 5.5+

[](#for-laravel-55)

Require this package with composer:

```
composer require aneeskhan47/laravel-pagination-merge

```

The service provider will be auto-discovered. You do not need to add the provider anywhere.

### For Laravel 5.0 to 5.4

[](#for-laravel-50-to-54)

Require this package with composer:

```
composer require aneeskhan47/laravel-pagination-merge

```

Find the `providers` key in `config/app.php` and register the PaginationMerge Service Provider.

```
'providers' => [
    // ...
    Aneeskhan47\PaginationMerge\PaginationMergeServiceProvider::class,
]
```

Find the `aliases` key in `config/app.php` and register the PaginationMerge alias.

```
'aliases' => [
    // ...
    'PaginationMerge' => Aneeskhan47\PaginationMerge\Facades\PaginationMerge::class,
]
```

🚀 Usage
-------

[](#-usage)

```
use App\Models\Post;
use App\Models\Event;
use Aneeskhan47\PaginationMerge\Facades\PaginationMerge;

class PublicationsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @param \Illuminate\Http\Request $request
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $events = Event::latest()->paginate(5);
        $posts = Post::latest()->paginate(5);

        $publications = PaginationMerge::merge($events, $posts)
                                       ->sortByDesc('created_at')
                                       ->get();

        // since get() will return \Illuminate\Pagination\LengthAwarePaginator
        // you can continue using paginator methods like these etc:

        $publications->withPath('/admin/users')
                     ->appends(['sort' => 'votes'])
                     ->withQueryString()
                     ->fragment('users')
                     ->setPageName('publications_page');

        return view('publications.index', compact('publications'));
    }
}
```

💰 Support the development
-------------------------

[](#-support-the-development)

**Do you like this package? Support it by donating**

- PayPal: [Donate](https://www.paypal.com/paypalme/aneeskhan47)

🧪 Testing
---------

[](#-testing)

```
composer test
```

📝 Changelog
-----------

[](#-changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

🤝 Contributing
--------------

[](#-contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

🔒 Security
----------

[](#-security)

If you discover any security-related issues, please email  instead of using the issue tracker.

🙌 Credits
---------

[](#-credits)

- [Anees Khan](https://github.com/aneeskhan47)
- [All Contributors](../../contributors)

📜 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

🔧 Laravel Package Boilerplate
-----------------------------

[](#-laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance46

Moderate activity, may be stable

Popularity36

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 91.7% 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 ~144 days

Recently: every ~252 days

Total

8

Last Release

410d ago

PHP version history (2 changes)v1.0.0PHP ^7.2|^8.0|^8.1

v1.0.4PHP ^7.2|^8.0|^8.1|^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/a90a10890bedc5d9ef6888329f3ce4de29869567404ad4f32cd58491525720b9?d=identicon)[aneeskhan47](/maintainers/aneeskhan47)

---

Top Contributors

[![aneeskhan47](https://avatars.githubusercontent.com/u/30714223?v=4)](https://github.com/aneeskhan47 "aneeskhan47 (33 commits)")[![Alocvetic](https://avatars.githubusercontent.com/u/68153764?v=4)](https://github.com/Alocvetic "Alocvetic (1 commits)")[![Ninako](https://avatars.githubusercontent.com/u/5570902?v=4)](https://github.com/Ninako "Ninako (1 commits)")[![prjanitor](https://avatars.githubusercontent.com/u/272426700?v=4)](https://github.com/prjanitor "prjanitor (1 commits)")

---

Tags

aneeskhan47laravel-pagination-merge

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[illuminate/pipeline

The Illuminate Pipeline package.

9346.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)[mrmarchone/laravel-auto-crud

Laravel Auto CRUD helps you streamline development and save time.

28711.8k2](/packages/mrmarchone-laravel-auto-crud)

PHPackages © 2026

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