PHPackages                             dongrim/datatable-inertia - 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. dongrim/datatable-inertia

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

dongrim/datatable-inertia
=========================

Easy build datatable for InertiaJS on Laravel

0.0.5(3y ago)315MITPHPPHP &gt;=7.4.0

Since Sep 28Pushed 3y ago1 watchersCompare

[ Source](https://github.com/YaroslavFedan/datatable-inertia)[ Packagist](https://packagist.org/packages/dongrim/datatable-inertia)[ RSS](/packages/dongrim-datatable-inertia/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (6)Versions (6)Used By (0)

Datatable-Inertia
=================

[](#datatable-inertia)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![tests](https://github.com/YaroslavFedan/datatable-inertia/actions/workflows/datatable-inertia-tests.yml/badge.svg?branch=master)](https://github.com/YaroslavFedan/datatable-inertia/actions/workflows/datatable-inertia-tests.yml)

This package provides a DataTables-like experience for Inertia.js with support for searching, filtering, sorting and pagination.

Laravel compatibility
---------------------

[](#laravel-compatibility)

Laraveldatatable-inertia6.0-9.x0.0.xInstallation
------------

[](#installation)

**Install the package via composer.**

```
composer require dongrim/datatable-inertia
```

Config Files
------------

[](#config-files)

**In order to edit the default configuration you may execute:**

```
php artisan vendor:publish --provider="Dongrim\DatatableInertia\DatatableInertiaServiceProvider"
```

Usage
-----

[](#usage)

- ### **Generate a datatable**

    [](#generate-a-datatable)

```
php artisan datatable:make SomeDatatable
```

By default, the command generates the `SomeDatatable` class in the \\App\\Datatables directory
If you want to change the destination path of a class, you can use one of these methods:

1. Specify a new path in the file /config/datatables.php

```
'basePath' => '\App\Datatables'
```

2. Run command `php artisan datatable:make` without specifying the name of the generated class and answer questions.

- ### **How to use in Controller**

    [](#how-to-use-in-controller)

To generate data, a `table` macro has been created for Inertia\\Response.
You can take advantage of dependency injection

```
public function index(PostDatatable $datatable)
{
    return Inertia::render('Post/Index')->table($datatable);
}
```

Or just give the classpath

```
public function index()
{
    return Inertia::render('Post/Index')->table(PostDatatable::class); // '\App\Datatables\PostDatatable'
}
```

If you need to pass additional data, use the usual method of passing data in InertiaJs

```
public function index(PostDatatable $datatable)
{
    return Inertia::render('Post/Index', ['data' => 'some data'])->table($datatable);
}
```

- ### **How to use Datatable class**

    [](#how-to-use-datatable-class)

By default datatable class is generated in minimal configuration

For example

```
namespace \App\Datatables;

use Illuminate\Database\Eloquent\Builder;
use Dongrim\DatatableInertia\DatatableInertia;

class PostDatatable extends DatatableInertia
{
    /**
     * Eloquent datatable query builder
     *
     * @return Builder
     */
    public function query(): Builder
    {
        // code
    }
}
```

### Public properties available in the class:

[](#public-properties-available-in-the-class)

PropertiesTypeDefaultDescription`datatableName`string'datatable'The name of the object containing all returned data from datatable`perPageKey`string'per\_page'The key in the request responsible for changing the number of displayed elements on the page (only when rendering on the client side)`itemsPerPage`int15Parameter responsible for the number of displayed elements on the page by default`serverSide`boolfalseParameter responsible for the server or client side rendering> Note that these options are set globally in the config/datatables.php configuration file.
>  You can override them directly in you the class

### Public methods available in the class:

[](#public-methods-available-in-the-class)

MethodResponse typeRequiredDescription`query``\Illuminate\Database\Eloquent\Builder``required`Creates prepared Eloquent query builder`modify``\Illuminate\Database\Eloquent\Model``optional`Changing the value of returned fields`columns``array``optional`If method columns not implemented in the derived class, will be returned all fillable fields`guard``array``optional`Adding access rights to a specific entry to change, delete, etc.`filters``array``optional`Adding filters and their values (server-side rendering only)For ExampleDatatable:

```
namespace App\Datatables;

use App\Models\Post;
use Illuminate\Support\Facades\Auth;
use Illuminate\Database\Eloquent\Builder;
use Dongrim\DatatableInertia\DatatableInertia;

class PostDatatable extends DatatableInertia
{
    public $datatableName = 'post_datatable';

    public $perPageKey = 'post_per_page';

    public $itemsPerPage = 25;

    public $serverSide = true;

    public function query(): Builder
    {
        return Post::select('posts.*', 'users.username as author_name')
            ->join('users', function ($join) {
                $join->on('users.id', '=', 'posts.author_id');
            })
            ->when(request()->search, function ($query, $search) {
                return $query->where('title', 'like', "{$search}%")
                    ->orWhere('text', 'like', "{$search}%")
                    ->orWhere('users.username', 'like', "{$search}%");
            })
            ->when(request()->sort, function ($query, $sort) {
                $query->withoutGlobalScopes();
                $table = ($sort == 'id') ? "posts." : "";
                $query->orderBy($table . $sort, request()->order ?? 'asc');
            })
            ->when(request()->active, function ($query, $active) {
                $active = $active === 'true' ? true : false;
                $query->where('posts.active', $active);
            });
    }

    public function columns(): array
    {
        return ['id', 'position', 'active', 'title', 'text', 'author_name'];
    }

    public function filters(): array
    {
        return ['sort', 'order', 'search', 'active'];
    }

    public function guard($data): array
    {
        return [
            'edit' => Auth::user()->can('post.edit') ? route('post.edit', $data->id) : null,
            'destroy' => Auth::user()->can('post.destroy') ? route('post.destroy', $data->id) : null,
            'restore' => Auth::user()->can('post.restore') ? route('post.restore', $data->id) : null,
        ];
    }

    public function modify($data)
    {
        $data->text = str($data->text)->substr(0, 100);
        return $data;
    }

}
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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

Every ~0 days

Total

5

Last Release

1369d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/501d625d840cbef7427e30a2c3fadea7693377e67feff44a27eb453ad9147121?d=identicon)[dongrim](/maintainers/dongrim)

---

Top Contributors

[![YaroslavFedan](https://avatars.githubusercontent.com/u/8318982?v=4)](https://github.com/YaroslavFedan "YaroslavFedan (17 commits)")

---

Tags

phplaravelinertiadatatableinertiajs

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/dongrim-datatable-inertia/health.svg)

```
[![Health](https://phpackages.com/badges/dongrim-datatable-inertia/health.svg)](https://phpackages.com/packages/dongrim-datatable-inertia)
```

###  Alternatives

[firefly-iii/data-importer

Firefly III Data Import Tool.

8015.8k](/packages/firefly-iii-data-importer)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17878.9k](/packages/markwalet-nova-modal-response)[verschuur/laravel-robotstxt

Set the robots.txt content dynamically based on the Laravel app environment.

43429.9k1](/packages/verschuur-laravel-robotstxt)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

1320.9k4](/packages/team-nifty-gmbh-tall-datatables)

PHPackages © 2026

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