tooinfinity / inertia-tank-table
handle inertia server side table with tank table
Fund package maintenance!
tooinfinity
Requires
- php: ^8.3.0
- dompdf/dompdf: ^2.0
- inertiajs/inertia-laravel: ^2.0
- laravel/framework: ^11.0|^12.0
- phpoffice/phpspreadsheet: ^1.29
- spatie/laravel-data: ^4.15
- spatie/laravel-package-tools: ^1.92
- spatie/laravel-query-builder: ^6.3
Requires (Dev)
- laravel/pint: ^1.22.0
- orchestra/testbench: ^9.0
- orchestra/testbench-core: ^9.0
- peckphp/peck: ^0.1.3
- pestphp/pest: ^3.8.1
- pestphp/pest-plugin-type-coverage: ^3.5
- phpstan/phpstan: ^1.12.23
- rector/rector: ^1.2.10
- roave/security-advisories: dev-latest
- symfony/var-dumper: ^7.2.3
This package is auto-updated.
Last update: 2025-04-26 21:18:58 UTC
README
A Laravel package that provides a powerful table component for Inertia.js + React applications with TanStack Table integration. Built to handle server-side operations efficiently with features like sorting, filtering, pagination, and exports.
Features
- 🔄 Server-side sorting, filtering, and pagination
- 🔍 Global search across multiple fields
- ⚡ TanStack Table integration for optimal performance
- 📊 Multiple column types (Text, Numeric, Date, Actions)
- 🔎 Advanced filtering options
- ⚙️ Customizable row actions
- 📑 Export to Excel, CSV, and PDF
- 🎨 Tailwind CSS styling
- 🔒 Secure export handling with signed URLs
Installation
composer require tooinfinity/inertia-tank-table
Publish the configuration and assets:
php artisan vendor:publish --provider="TooInfinity\InertiaTankTable\InertiaTankTableServiceProvider"
Quick Start
- Create a new table class:
php artisan make:tank-table Users
- Define your table configuration in
app/Tables/Users.php
:
class Users extends TankTable { protected string $model = User::class; protected string $defaultSort = 'name'; protected array $searchableFields = ['name', 'email']; protected function buildQuery(): Builder { return User::query(); } protected function getColumns(): array { return [ (new TextColumn('name', 'Full Name'))->sortable(), (new TextColumn('email', 'Email'))->sortable(), // Add more columns... ]; } }
- Use in your Inertia controller:
public function index() { return Inertia::render('Users/Index', [ 'users' => \App\Tables\Users::make() ]); }
- In your React component:
import { TankTable } from '@/Components/TankTable'; export default function Users({ users }) { return ( <TankTable {...users} signedExportUrl={usePage().props.tankTableExportUrl} tableClass="App\\Tables\\Users" /> ); }
Available Column Types
TextColumn
: For text and string valuesNumericColumn
: For numbers with optional formattingDateColumn
: For dates with customizable formatsActionColumn
: For row actions like edit, delete, etc.
Filters
Available filter types:
TextFilter
: Text searchNumericFilter
: Number range filteringBooleanFilter
: Yes/No filtersDateFilter
: Date range with nullable option
Exports
Supported export formats:
- Excel (.xlsx)
- CSV
Row Actions
Built-in action types:
EditAction
: Link-based edit actionDeleteAction
: Delete with confirmationStatusAction
: Custom status toggle actions
Configuration
You can customize the default settings in config/inertia-tank-table.php
:
return [ 'pagination' => [ 'per_page' => 10, 'page_name' => 'page', ], 'sort' => [ 'direction' => 'asc', ], 'namespace' => 'App\\Tables', ];
Security
Exports are protected with signed URLs and middleware to prevent unauthorized access.
Requirements
- PHP 8.3+
- Laravel 11.0+
- Inertia.js 2.0+
- React 18+
License
The MIT License (MIT). Please see License File for more information.