Download the PHP package starter-solutions/inertia-data-table without Composer
On this page you can find all versions of the php package starter-solutions/inertia-data-table. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download starter-solutions/inertia-data-table
More information about starter-solutions/inertia-data-table
Files in starter-solutions/inertia-data-table
Package inertia-data-table
Short Description Laravel side of Starter Solutions Inertia Data Table
License MIT
Informations about the package inertia-data-table
starter-solutions/inertia-data-table
Laravel backend for server-driven data tables with Inertia.js. It adds a dataTable() macro to Eloquent builders, query builders, and collections and works with @starter-solutions/inertia-data-table-vue.
Features
- Pagination, filtering, and sorting owned by the backend
- Independent state for multiple tables through table keys
- URL-query or session-backed table state
- Sort whitelists declared on models
- Recursive sorting through singular Eloquent relations
- Sort aliases for accessors
- Inline callbacks and container-resolved sort classes
- Flat paginator and Laravel
JsonResourceresponses
Installation
Laravel discovers the service provider automatically. To customize parameter names, middleware, or defaults, publish the configuration:
Quick start
Declare the columns the frontend may sort by:
Return the paginator as an Inertia prop:
The tableKey must match the key passed to the Vue useDataTable() composable.
Allowed sorts
allowed_sorts has three distinct states:
null: any base-model column may be sorted[]: sorting is disabled['id', 'name']: only the listed public keys are accepted
Prefer an explicit #[AllowedSorts] attribute in production:
You can override the model attribute for one table:
Invalid configured columns or relation paths are ignored and logged as structured warnings. The response reports sort_by: null when a requested sort could not be applied.
Sorting related models
Sortable fields are resolved automatically from eager-loaded models:
The resolved public keys include author.name and author.email. Nested eager loads such as author.profile.company.name are resolved recursively.
Automatic relation sorting supports singular BelongsTo, HasOne, HasOneThrough, and MorphOne relations. A multi-value relation such as HasMany needs a custom sort callback so the aggregate or selected row is explicit.
Sorting accessors and aliases
Map an accessor's public key to its backing database column:
The frontend uses display_name; SQL orders by name.
Custom sort callbacks
For one-off SQL expressions, pass a keyed closure:
PHP attributes cannot contain closures. Use an invokable class for reusable or attribute-based custom sorts:
Sort classes are resolved through Laravel's container and may use constructor injection. Callback sorts must have a public string key.
Filtering and additional metadata
The filter callback receives the active filter values. Extra values can be returned beside the pagination metadata:
Vue can read this with additional or getAdditional('filters.statuses', []).
Query builders and collections
The macro is also available on the database query builder:
Collections are filtered, sorted, and paginated in memory. Dot notation works for nested values:
Relation discovery, accessor aliases, and SortCallback classes apply only to Eloquent builders.
Multiple tables
Use a unique table key and prop for each table:
Only the table identified by the request's tableKey consumes URL query state. Other tables use their independent session state.
JsonResource wrapping
Both flat paginator data and Laravel resource collections are supported by the Vue package:
Configuration
Published config/inertia-data-table.php options include:
License
MIT © Starter Solutions
All versions of inertia-data-table with dependencies
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/pagination Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
inertiajs/inertia-laravel Version ^2.0|^3.0