PHPackages                             savannabits/laravel-pagetables - 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. savannabits/laravel-pagetables

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

savannabits/laravel-pagetables
==============================

Laravel Pagetables is a Server Side Adapter for Datatables using the default Laravel Pagination.

v1.1.0(3y ago)39671MITPHPPHP ^7.4|^8.0

Since Jan 18Pushed 3y ago2 watchersCompare

[ Source](https://github.com/savannabits/laravel-pagetables)[ Packagist](https://packagist.org/packages/savannabits/laravel-pagetables)[ Docs](https://github.com/savannabits/laravel-pagetables)[ GitHub Sponsors](https://github.com/sponsors/savannabits)[ RSS](/packages/savannabits-laravel-pagetables/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (3)Versions (4)Used By (1)

Datables Using Laravel's Pagination format
==========================================

[](#datables-using-laravels-pagination-format)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5292de8b826da2defd5a1b32e2ec4bbebb2ed0a442785d52cc868d81c272c3a7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736176616e6e61626974732f6c61726176656c2d706167657461626c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/savannabits/laravel-pagetables)[![GitHub Tests Action Status](https://camo.githubusercontent.com/ec216d4f582a29c694b20bfb032c0af06117f1a07890e17de9f838442741e986/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f736176616e6e61626974732f6c61726176656c2d706167657461626c65732f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/savannabits/laravel-pagetables/actions?query=workflow%3ATests+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/551b97cca8405213bccdb069409539972f174c5f447dfb989519d5bfa9079a29/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736176616e6e61626974732f6c61726176656c2d706167657461626c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/savannabits/laravel-pagetables)

Generate Laravel pagination with support to search, sort, per\_page and page queries. The Datatables support searching and ordering by children/parent relationships e.g user.role.name.

If you are on Vue.js, we recommend using the **[Pagetables Component](https://github.com/savannabits/pagetables)** which renders nice datatables styled in tailwindcss and supports the payload from this package out of the box.

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

[](#installation)

You can install the package via composer:

```
composer require savannabits/laravel-pagetables
```

Usage
-----

[](#usage)

Under the hood, this package uses laravel pagination and returns a LengthAwarePaginator object together with the columns specified. The package has a Column class which helps to construct columns with names and other properties for the sake of frontend rendering and formatting. Use the package in three simple steps:

1. Specify the columns as Savannabits\\Pagetables\\Column\[\] array.
2. Create the datatables from a query, passing in the columns array from step 1.
3. Query the controller method from the frontend with parameters such as `search`,`sort`,`per_page`, `sort_direction` and `page`

**Example**In the Controller:

```
use Savannabits\Pagetables\Column;
use Savannabits\Pagetables\Pagetables;
use App\Models\Article;
$columns = [
            Column::name("id")->title("ID")->sortDesc()->searchable(),
            Column::name("slug")->title("Slug")->sort()->searchable(),
            Column::name("name")->title("Name")->sort()->searchable(),
            Column::name("weighted_cost")->title("Weighted Cost")->sort()->searchable(),
            Column::name("itemGroup.name")->title("Group")->sort()->searchable(),
            Column::name("actions")->title("")->raw(true),
        ];
$dt = Pagetables::of(Article::where("enabled", "=",true))
            ->columns($columns)
            ->make(true);
return response()->json($dt);
```

API Request from your client:

```
GET https://myserver.test/api/articles?search=&per_page=10&sort=weighted_cost&sort_direction=asc&page=1
```

Response JSON:

```
  {
    "current_page": 1,
    "data": [
        {
            "id": 1949,
            "slug": "mocha-frappe-500-ml-pa",
            "name": "MOCHA FRAPPE 500 ML (PA)",
            "description": "Created while importing Recipe .MOCHA FRAPPE 500 ML from Micros by smaosa at 2019-12-19 16:52:15",
            "article_type_id": 1,
            "item_group_id": 1,
            "default_depot_id": 44,
            "derived_unit_id": 22,
            "last_purchase_price": 0,
            "last_ordered_quantity": 0,
            "last_order_time": null,
            "lifespan_days": 2,
            "is_product": true,
            "last_received_quantity": 0,
            "last_receiving_price": 0,
            "last_received_at": null,
            "weighted_cost": 0,
            "enabled": true,
            "created_at": "2019-12-19 16:52:15",
            "updated_at": "2020-08-31 20:41:19",
            "is_consumable": 0,
            "api_route": "https://myserver.test/api/articles",
            "item_group": {
                "id": 1,
                "slug": "bakery-products",
                "name": "Bakery Products",
                "description": "Assigned to Profit Contribution. Imported at 2019-12-19 13:59:43 by smaosa",
                "enabled": true,
                "major_group_id": 6,
                "created_at": "2019-12-19 13:59:43",
                "updated_at": "2020-08-31 20:41:18",
                "api_route": "https://myserver.test/api/item-groups"
            }
        },
        {"id": 1950 },
        {"id": 1951 }
    ],
    "first_page_url": "https://myserver.test/api/articles?page=1",
    "from": 1,
    "last_page": 189,
    "last_page_url": "https://myserver.test/api/articles?page=189",
    "links": [
        {
            "url": null,
            "label": "&laquo; Previous",
            "active": false
        },
        {
            "url": "https://myserver.test/api/articles?page=1",
            "label": 1,
            "active": true
        },
        {
            "url": "https://myserver.test/api/articles?page=2",
            "label": 2,
            "active": false
        },
        {
            "url": "https://myserver.test/api/articles?page=3",
            "label": 3,
            "active": false
        },
        {
            "url": "https://myserver.test/api/articles?page=4",
            "label": 4,
            "active": false
        },
        {
            "url": "https://myserver.test/api/articles?page=5",
            "label": 5,
            "active": false
        },
        {
            "url": "https://myserver.test/api/articles?page=6",
            "label": 6,
            "active": false
        },
        {
            "url": "https://myserver.test/api/articles?page=7",
            "label": 7,
            "active": false
        },
        {
            "url": "https://myserver.test/api/articles?page=8",
            "label": 8,
            "active": false
        },
        {
            "url": "https://myserver.test/api/articles?page=9",
            "label": 9,
            "active": false
        },
        {
            "url": "https://myserver.test/api/articles?page=10",
            "label": 10,
            "active": false
        },
        {
            "url": null,
            "label": "...",
            "active": false
        },
        {
            "url": "https://myserver.test/api/articles?page=188",
            "label": 188,
            "active": false
        },
        {
            "url": "https://myserver.test/api/articles?page=189",
            "label": 189,
            "active": false
        },
        {
            "url": "https://myserver.test/api/articles?page=2",
            "label": "Next &raquo;",
            "active": false
        }
    ],
    "next_page_url": "https://myserver.test/api/articles?page=2",
    "path": "https://myserver.test/api/articles",
    "per_page": "10",
    "prev_page_url": null,
    "to": 10,
    "total": 1884,
    "columns": [
        {
            "title": "ID",
            "name": "id",
            "raw": false,
            "sortable": true,
            "searchable": true,
            "sort_key": "id",
            "search_key": "id",
            "sort_direction": "desc"
        },
        {
            "title": "Slug",
            "name": "slug",
            "raw": false,
            "sortable": true,
            "searchable": true,
            "sort_key": "slug",
            "search_key": "slug",
            "sort_direction": "asc"
        },
        {
            "title": "Name",
            "name": "name",
            "raw": false,
            "sortable": true,
            "searchable": true,
            "sort_key": "name",
            "search_key": "name",
            "sort_direction": "asc"
        },
        {
            "title": "Weighted Cost",
            "name": "weighted_cost",
            "raw": false,
            "sortable": true,
            "searchable": true,
            "sort_key": "weighted_cost",
            "search_key": "weighted_cost",
            "sort_direction": "asc"
        },
        {
            "title": "Group",
            "name": "itemGroup.name",
            "raw": false,
            "sortable": true,
            "searchable": true,
            "sort_key": "itemGroup.name",
            "search_key": "itemGroup.name",
            "sort_direction": "asc"
        },
        {
            "title": "",
            "name": "actions",
            "raw": true,
            "sortable": false,
            "searchable": false,
            "sort_key": "actions",
            "search_key": "actions",
            "sort_direction": "asc"
        }
    ]
}
```

From here, how you use the payload to render the datatable is entirely up to you.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

Contributing
------------

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Sam Arossi Maosa](https://github.com/coolsam726)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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

Every ~510 days

Total

2

Last Release

1430d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0c07613c8ab7356eb1d69752c0f2dc5802aeca61029ea8d3e6b9e58bfacee6af?d=identicon)[coolsam726](/maintainers/coolsam726)

---

Top Contributors

[![coolsam726](https://avatars.githubusercontent.com/u/5610289?v=4)](https://github.com/coolsam726 "coolsam726 (13 commits)")

---

Tags

laraveldatatablesvuesavannabitslaravel-pagetablespagetables

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/savannabits-laravel-pagetables/health.svg)

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

###  Alternatives

[rappasoft/laravel-livewire-tables

A dynamic table component for Laravel Livewire

2.0k2.7M31](/packages/rappasoft-laravel-livewire-tables)[ijpatricio/mingle

Use Vue and React in Laravel Livewire Applications.

43445.4k2](/packages/ijpatricio-mingle)[savannabits/primevue-datatables

Easy Laravel Server-Side implementation of PrimeVue Datatables

337.7k1](/packages/savannabits-primevue-datatables)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[openskill/datatable

This is a Laravel 5 package for the server and client side of DataTables (http://datatables.net/)

5511.2k1](/packages/openskill-datatable)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

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