PHPackages                             a-dob/preview-paginator - 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. a-dob/preview-paginator

ActiveLibrary

a-dob/preview-paginator
=======================

Laravel pagination with different size for first page (preview-paginator)

1.0.0(4y ago)09MITPHPPHP ^7.4|^8.0

Since Jul 19Pushed 4y ago1 watchersCompare

[ Source](https://github.com/a-dob/preview-paginator)[ Packagist](https://packagist.org/packages/a-dob/preview-paginator)[ RSS](/packages/a-dob-preview-paginator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Laravel pagination for models with different page sizes (preview-paginator)
===========================================================================

[](#laravel-pagination-for-models-with-different-page-sizes-preview-paginator)

This package allows you to add a local scope to your Model.
The Pagination class implements the `Illuminate\Pagination\AbstractPaginator`contract and it is similar to the basic simplePaginate method.

Installation
============

[](#installation)

```
composer require a-dob/preview-paginator

```

Add PreviewPaginated trait to models
====================================

[](#add-previewpaginated-trait-to-models)

Add `Adob\PreviewPaginator\PreviewPaginated` trait to your model you want to paginate

```
use Illuminate\Database\Eloquent\Model;
use Adob\PreviewPaginator\PreviewPaginated;

class Post extends Model
{
    use PreviewPaginated;

    protected $initialQuantity = 2;

    protected $perPage = 5;

```

The `$initialQuantity` property sets the number of returned models on the first page by default.

The `$perPage` property sets the number of returned models on the remaining pages by default.

Usage
=====

[](#usage)

You may paginate Eloquent queries. In this example, we will paginate the `App\Models\User` model and indicate that we plan to display 5 records on first page and 15 records on the remaining pages. As you can see, the syntax is nearly identical to paginating query builder results:

```
use App\Models\User;

$users = User::previewPaginate(5, 15);

```

Of course, you may call the previewPaginate method after setting other constraints on the query, such as where clauses:

```
$users = User::where('votes', '>', 100)->previewPaginate(5, 15);

```

You may also use the previewPaginate method when paginating Eloquent models:

```
$users = User::where('votes', '>', 100)->previewPaginate(5, 15);

```

The first argument of the previewPaginated method specifies the number of returned models on the first page.

The second argument of the previewPaginated method specifies the number of returned models on the remaining pages.

If null is passed as the first argument, the initial quantity will be defined from the specified model property. If this property is not defined in the model the initial quantity will be `5`

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1754d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/23d9a47c5210c9697ecf36b5589382d64d053559d2787d64840563fa4c9f8134?d=identicon)[adob](/maintainers/adob)

---

Top Contributors

[![a-dob](https://avatars.githubusercontent.com/u/31900584?v=4)](https://github.com/a-dob "a-dob (5 commits)")

### Embed Badge

![Health badge](/badges/a-dob-preview-paginator/health.svg)

```
[![Health](https://phpackages.com/badges/a-dob-preview-paginator/health.svg)](https://phpackages.com/packages/a-dob-preview-paginator)
```

PHPackages © 2026

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