PHPackages                             machour/laravel-data-table - 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. machour/laravel-data-table

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

machour/laravel-data-table
==========================

A reusable, server-side DataTable system for Laravel + Inertia.js + React (TanStack Table). Define your table in a single PHP class — get sorting, filtering, pagination, exports, quick views, and a full-featured React UI out of the box.

0.0.6(2mo ago)1429↓46.4%1MITTypeScriptPHP ^8.2CI passing

Since Feb 15Pushed 2mo agoCompare

[ Source](https://github.com/machour/laravel-data-table)[ Packagist](https://packagist.org/packages/machour/laravel-data-table)[ RSS](/packages/machour-laravel-data-table/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (16)Versions (9)Used By (0)

Laravel DataTable
=================

[](#laravel-datatable)

A reusable, server-side DataTable system for **Laravel + Inertia.js + React** (TanStack Table v8). Define your table in a single PHP class — get sorting, filtering, pagination, exports, quick views, and a full-featured React UI out of the box.

Features
--------

[](#features)

- **Single-file backend** — One PHP class per model acts as both DTO and table configuration
- **Server-side everything** — Sorting, filtering, pagination handled by Spatie QueryBuilder
- **Operator-based filters** — URL format `filter[price]=gte:1000` with 14 operators (eq, neq, gt, gte, lt, lte, between, in, not\_in, contains, before, after, null, not\_null)
- **Quick Views** — Server-defined filter presets + user-saved custom views (localStorage)
- **Column ordering** — Drag-to-reorder via GripVertical handles, persisted to localStorage
- **Column pinning** — Automatic sticky columns for checkbox (`_select`) and actions (`_actions`)
- **Column groups** — Group columns under shared headers with custom background colors
- **Column visibility** — Toggle columns on/off, persisted to localStorage
- **Footer aggregations** — Per-page computed values (sum, avg, etc.) with custom rendering
- **XLSX/CSV export** — Via Maatwebsite Excel (optional peer dependency)
- **Bulk actions** — Checkbox selection with configurable action buttons
- **Row actions** — Per-row dropdown menu with visibility and variant support
- **Responsive** — Mobile popover for toolbar, horizontal scroll for wide tables
- **Feature flags** — Disable any feature via frontend `options` prop

Requirements
------------

[](#requirements)

### PHP

[](#php)

PackageVersionPHP^8.2Laravel^11.0 | ^12.0spatie/laravel-data^4.0spatie/laravel-query-builder^6.0**Optional:**

- `maatwebsite/excel ^3.1` — for XLSX/CSV export
- `spatie/laravel-typescript-transformer ^2.5` — for TypeScript type generation from DTOs

### JavaScript

[](#javascript)

Your project must be set up with [shadcn/ui](https://ui.shadcn.com) (React + Tailwind CSS).

The `shadcn add` command will automatically install all required shadcn components (button, table, checkbox, etc.) and npm dependencies (`@tanstack/react-table`, `@inertiajs/react`, `date-fns`, `lucide-react`).

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

[](#installation)

### 1. Install the Composer package

[](#1-install-the-composer-package)

```
composer require machour/laravel-data-table
```

### 2. Install the React components via shadcn

[](#2-install-the-react-components-via-shadcn)

```
npx shadcn@latest add ./vendor/machour/laravel-data-table/react/public/r/data-table.json
```

This copies all DataTable components into your project (you own the code!) and installs the required shadcn UI dependencies automatically.

### 3. (Optional) Install Maatwebsite Excel for export support

[](#3-optional-install-maatwebsite-excel-for-export-support)

```
composer require maatwebsite/excel
```

Quick Start
-----------

[](#quick-start)

### 1. Scaffold with the Artisan command

[](#1-scaffold-with-the-artisan-command)

The fastest way to get started:

```
php artisan make:data-table Product
```

This generates:

- `app/DataTables/ProductDataTable.php` — your DataTable class
- `resources/js/pages/product-table.tsx` — a React page stub

Available options:

```
# Include export support (HasExport trait)
php artisan make:data-table Product --export

# Also append a route to routes/web.php
php artisan make:data-table Product --route

# Custom route file
php artisan make:data-table Product --route --route-file=routes/admin.php

# Custom page output path
php artisan make:data-table Product --page-path=resources/js/pages/admin
```

### 2. Or create your DataTable class manually

[](#2-or-create-your-datatable-class-manually)

```
