yuisalabs / voltia-datatable
Modern DataTable for Laravel Inertia.js. Clean syntax, customizable, testable and production ready UX
Fund package maintenance!
yuisa
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/yuisalabs/voltia-datatable
Requires
- php: ^8.3
- illuminate/contracts: ^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
This package is not auto-updated.
Last update: 2026-01-11 07:30:57 UTC
README
Modern, elegant DataTable package for Laravel with Inertia.js support. Built with clean syntax, fully customizable, and production-ready.
โจ Features
- ๐ Easy to use - Simple, fluent API for defining tables
- ๐ Full-text search - Search across multiple columns
- ๐ Sorting - Sort by any column with direction control
- ๐ Filters - Multiple filter types (Select, Text, Boolean, DateRange)
- ๐ Pagination - Built-in pagination with customizable per-page options
- ๐ฏ Type-safe - Full PHP 8.3+ type hints
- ๐ Eager loading - Automatic relationship eager loading
- โก Performance - Optimized queries for large datasets
- ๐จ Inertia.js ready - Perfect for Vue/React frontends
๐ฆ Installation
Install the package via composer:
composer require yuisalabs/voltia-datatable
Publish the config file:
php artisan vendor:publish --tag="voltia-datatable-config"
๐ Quick Start
1. Generate a DataTable Class
php artisan make:datatable UserTable --model=User
This creates app/Tables/UserTable.php:
<?php namespace App\Tables; use Illuminate\Database\Eloquent\Builder; use App\Models\User; use Yuisalabs\VoltiaDatatable\Table; use Yuisalabs\VoltiaDatatable\Column; use Yuisalabs\VoltiaDatatable\Filters\SelectFilter; use Yuisalabs\VoltiaDatatable\Filters\DateRangeFilter; class UserTable extends Table { public function query(): Builder { return User::query(); } public function columns(): array { return [ Column::make('id', 'ID') ->sortable(), Column::make('name', 'Name') ->sortable() ->searchable(), Column::make('email', 'Email') ->sortable() ->searchable(), Column::make('status', 'Status') ->sortable() ->format(fn ($row, $value) => ucfirst($value)), Column::make('created_at', 'Created At') ->sortable() ->format(fn ($row, $value) => $value?->format('Y-m-d H:i:s')), ]; } protected function filters(): array { return [ 'status' => new SelectFilter('status', [ 'active' => 'Active', 'inactive' => 'Inactive', 'pending' => 'Pending', ]), 'created_at' => new DateRangeFilter('created_at'), ]; } }
2. Use in Controller
<?php namespace App\Http\Controllers; use App\Tables\UserTable; use Inertia\Inertia; class UserController extends Controller { public function index(UserTable $datatable) { return Inertia::render('Users/Index', [ 'datatable' => $datatable->make(), ]); } }
3. Frontend (Vue/React Example)
The datatable returns a structured response:
{ rows: [...], columns: [...], meta: { page: 1, perPage: 15, total: 100, from: 1, to: 15 }, sort: { sortBy: 'name', sortDirection: 'asc' }, search: 'john', filters: {...} }
๐ Usage
Column Definition
Column::make('key', 'Label') ->sortable() // Enable sorting ->searchable() // Enable searching ->hidden() // Hide column ->align('center') // Alignment: left, center, right ->minWidth(150) // Minimum width in pixels ->format(fn ($row, $value) => ...) // Custom formatting
Working with Relationships
public function columns(): array { return [ Column::make('user.name', 'User Name') ->sortable() ->searchable(), Column::make('user.email', 'Email') ->searchable(), ]; }
The package automatically eager loads the user relationship!
Available Filters
SelectFilter
'status' => new SelectFilter('status', [ 'active' => 'Active', 'inactive' => 'Inactive', ])
TextFilter
'search' => new TextFilter('column_name')
BooleanFilter
'is_verified' => new BooleanFilter('is_verified')
DateRangeFilter
'created_at' => new DateRangeFilter('created_at')
Custom Queries
public function query(): Builder { return User::query() ->where('status', 'active') ->with('roles'); }
Custom Formatting
Column::make('price', 'Price') ->format(fn ($row, $value) => 'Rp ' . number_format($value, 0, ',', '.')) Column::make('status', 'Status') ->format(fn ($row, $value) => match($value) { 'active' => 'โ Active', 'inactive' => 'โ Inactive', default => 'โธ Pending' })
โ๏ธ Configuration
Published config file (config/voltia-datatable.php):
return [ 'default_per_page' => 15, 'per_page_options' => [10, 15, 25, 50, 100], 'max_per_page' => 100, 'query_string' => true, 'date_format' => 'Y-m-d', ];
๐งช Testing
composer test
๐ Changelog
Please see CHANGELOG for more information on what has changed recently.
๐ค Contributing
Please see CONTRIBUTING for details.
๐ Security
Please review our security policy on how to report security vulnerabilities.
๐ฅ Credits
๐ License
The MIT License (MIT). Please see License File for more information.