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

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

steelants/datatable
===================

Simple Datatable class based on Laravel and livewire

2.7.5(1w ago)24.9k↓55.1%1MITPHP

Since Jun 23Pushed 2w ago1 watchersCompare

[ Source](https://github.com/steelants/Livewire-DataTable)[ Packagist](https://packagist.org/packages/steelants/datatable)[ RSS](/packages/steelants-datatable/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (32)Versions (76)Used By (1)

Livewire DataTable
==================

[](#livewire-datatable)

### Created by: [SteelAnts s.r.o.](https://www.steelants.cz/)

[](#created-by-steelants-sro)

[![Total Downloads](https://camo.githubusercontent.com/0de31ad0a80961f6bf8d069979819bbdbe9aa99cff6f27064ca12661cf4133a7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f737465656c616e74732f646174617461626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/steelants/datatable)

#### Docker Build

[](#docker-build)

- is handeled by gittea server

```
  git checkout master
  git pull origin master
  git pull origin dev
  git tag 2.3.2
  git push --tags
  git checkout dev
```

Usage
-----

[](#usage)

```
namespace App\Livewire;

use App\Models\User;
use SteelAnts\DataTable\Livewire\DataTableComponent;
use Illuminate\Database\Eloquent\Builder;
use SteelAnts\DataTable\Traits\UseDatabase;

class UserTable extends DataTableComponent
{
    Use UseDatabase;
	// or UseDatabaseEloquent, if you want to receive model instead ov serialized array

    // Get model query
    public function query(): Builder
    {
        return User::query();
    }

    // Set headers
    public function headers(): array
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'email' => 'E-mail',
        ];
    }

    // Set actions
    public function actions($item) : array
    {
        return [
            [
                // livewire action
                'type' => "livewire",
                'action' => "remove",
                'parameters' => $item['id'],
                'text' => "Remove",
                'actionClass' => 'text-danger',
                'iconClass' => 'fas fa-trash',
                'confirm' => 'Are you sure you want to delete this post?',
            ],
            [
                // url action
                'type' => "url",
                'url' => rounte('user.show', [id => $item['id']]),
                'text' => "Show",
                'iconClass' => 'fas fa-eye',
            ]
        ];
    }

    // Custom render of 'name' column
    public function renderColumnName($value, $row){
        return ''.e($value).'';
    }

    // Transform order column on raw order column (optional)
    public function orderColumnName(){
         return 'CAST(name AS STRING)';
    }

    // Livewire actions
    public function remove($id){
        User::find($id)->delete();
    }
}
```

### Using without query / models

[](#using-without-query--models)

```
    // instead of method query() implement dataset()
    public function dataset(): array
    {
        return [
            [
                'id' => '1',
                'name' => 'Name 1',
                'email' => 'E-mail 1',
            ],
            [
                'id' => '2',
                'name' => 'Name 2',
                'email' => 'E-mail 2',
            ],
            // ...
        ];
    }
```

### Render

[](#render)

```
@livewire('user-table', [], key('data-table'))
```

### Dev Enviroment

[](#dev-enviroment)

1. Clone Repo to `[LARVEL-ROOT]/packages/`
2. Modify ;composer.json`

```
    "autoload": {
        "psr-4": {
            ...
            "SteelAnts\\DataTable\\": "packages/Livewire-DataTable/src/"
            ...
        }
    },
```

3. Add (code below) to: `[LARVEL-ROOT]/bootstrap/providers.php`

```
SteelAnts\DataTable\DataTableServiceProvider::class,
```

Sorting
-------

[](#sorting)

Sorting is enabled by default. Set `$sortable = true` and optionally restrict which columns are sortable via `$sortableColumns`.

### Simple columns

[](#simple-columns)

Sorting by any direct column (string, int, bool) works out of the box:

```
public bool $sortable = true;
public array $sortableColumns = ['name', 'score', 'published'];
```

### BelongsTo relation

[](#belongsto-relation)

Use dot notation — the package resolves the join automatically:

```
// headers
'user.name' => 'User'

// sortBy
$sortBy = 'user.name';
```

### HasMany / MorphMany — sort by count

[](#hasmany--morphmany--sort-by-count)

Same dot notation. The package detects the relation type and generates a COUNT subquery:

```
// headers
'comments.id' => 'Comments'  // sorts by number of comments
'reactions.id' => 'Reactions' // sorts by number of reactions (morph-aware)

// sortBy
$sortBy = 'comments.id';
```

### Custom sort expression

[](#custom-sort-expression)

Override `orderColumn{Name}()` to return a raw SQL expression:

```
public function orderColumnName(): string
{
    return 'LOWER(name)';
}
```

---

Testing
-------

[](#testing)

The package uses [Pest](https://pestphp.com/) with [Orchestra Testbench](https://packages.tools/testbench) and an in-memory SQLite database.

Install dev dependencies:

```
composer install
```

Run all tests:

```
./vendor/bin/pest
```

Run only sorting tests:

```
./vendor/bin/pest tests/Feature/SortingTest.php
```

---

Configuration
-------------

[](#configuration)

```
// Enable sorting
public bool $sortable = true;

// Enable pagination
public bool $paginated = true;

// Enable fulltext search
public bool $searchable = true;
public bool $searchableColumns = [];

//Enable filters
public bool $filterable = true;
```

Render casts
------------

[](#render-casts)

New preferred way to customize render.

```
// Define cast by header key
public function renderCasts(): array
{
	return [
		'is_active' => BoolAsIcon::class,
	];
}
```

Example render cast

```
use SteelAnts\DataTable\RenderCasts\RenderCast;

class BoolAsIcon implements RenderCast
{
    public function render($key, $value, $model)
    {
        return '';
    }
}
```

Optional transforms methods
---------------------------

[](#optional-transforms-methods)

Original render customization.

```
// Transformace whole row on input (optional)
// Returns associative array
public function row(Model $row) : array
{
    return [
        'id' => $row->id,
    ];
}

// Transform one column on input (optional)
public function columnFoo(mixed $column) : mixed
{
    return $column;
}

// Transform whole row on output (optional)
// !!! NOTE: values are rendered with {!! !!}, manually escape values
public function renderRow(array $row) : array
{
    return [
        'id' => e($row['id'])
    ];
}

// Transform one column on output (optional)
// !!! NOTE: values are rendered with {!! !!}, manually escape values
public function renderColumnFoo(mixed $value, array $row) : string
{
    return e($value);
}
```

Filters methods
---------------

[](#filters-methods)

```
    //Add filters to header for specific columns
    public function headerFilters(): array
    {
        return [
            'column1Key' => ['type' => 'text'], //input type
            'column2Key' => ['type' => 'select', 'values' => ['value' => 'name', 'value2' => 'name2']], //this for select
            'column3Key' => ['type' => 'date'], //double input type (date,time,datetime-local)
        ];
    }

    //Add actions to header filters edit
    public function updatedHeaderFilter(){
        $this->validate([
            'headerFilter.column1Key' => 'nullable|string',
            'headerFilter.column2Key' => 'nullable|string',
            'headerFilter.column3Key.*' => 'nullable|date', //have two parameters "from" and "to"
        ]);
    }
```

Development
-----------

[](#development)

1. Create subfolder `/packages` at root of your laravel project
2. clone repository to sub folder `/packages` (you need to be positioned at root of your laravel project in your terminal)

```
git clone https://github.com/steelants/Livewire-DataTable.git ./packages/Livewire-DataTable
```

3. edit composer.json file

```
"autoload": {
	"psr-4": {
		"SteelAnts\\Modal\\": "packages/Livewire-Modal/src/"
	}
}
```

4. Add provider to `bootstrap/providers.php`

```
return [
	...
     SteelAnts\DataTable\DataTableServiceProvider::class,
	...
];
```

Contributors
------------

[](#contributors)

[ ![](https://camo.githubusercontent.com/ec127c943c7c4096848d2e428f1c513b4f546c6c28bdf9dec8e88c20e25c52d3/68747470733a2f2f636f6e747269622e726f636b732f696d6167653f7265706f3d737465656c616e74732f4c697665776972652d446174615461626c65)](https://github.com/steelants/Livewire-DataTable/graphs/contributors)Other Packages
--------------

[](#other-packages)

[steelants/laravel-auth](https://github.com/steelants/laravel-auth)

[steelants/laravel-boilerplate](https://github.com/steelants/Laravel-Boilerplate)

[steelants/datatable](https://github.com/steelants/Livewire-DataTable)

[steelants/form](https://github.com/steelants/Laravel-Form)

[steelants/modal](https://github.com/steelants/Livewire-Modal)

[steelants/laravel-tenant](https://github.com/steelants/Laravel-Tenant)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance98

Actively maintained with recent releases

Popularity25

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 54.6% 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 ~15 days

Total

71

Last Release

9d ago

Major Versions

v1.0.20 → 2.0.02024-03-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/3dc98a78c37f6eea8dc7942cdace8a805ba6430a020e6ab54c62a0639fe51f38?d=identicon)[JonatanRek](/maintainers/JonatanRek)

---

Top Contributors

[![GamerClassN7](https://avatars.githubusercontent.com/u/22167469?v=4)](https://github.com/GamerClassN7 "GamerClassN7 (112 commits)")[![Xinatorus](https://avatars.githubusercontent.com/u/17276754?v=4)](https://github.com/Xinatorus "Xinatorus (51 commits)")[![Imendin](https://avatars.githubusercontent.com/u/3099109?v=4)](https://github.com/Imendin "Imendin (42 commits)")

---

Tags

laravellivewirelivewire-componentsphp

###  Code Quality

TestsPest

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[nasirkhan/laravel-starter

A CMS like modular Laravel starter project.

1.4k2.7k](/packages/nasirkhan-laravel-starter)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

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

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

119.4k](/packages/tomshaw-electricgrid)[tanthammar/filament-extras

Filament macros, pages, fields, columns and other helpers

535.1k](/packages/tanthammar-filament-extras)[noerd/noerd

101.4k6](/packages/noerd-noerd)

PHPackages © 2026

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