Skip to content

Collections & arrays

Pass an array or collection when the data is already in memory:

use InertiaX\Components\Table\Columns\NumberColumn;
use InertiaX\Components\Table\Columns\TextColumn;
use InertiaX\Facades\InertiaX;
InertiaX::table('activity')
->data([
['id' => 1, 'event' => 'Account created'],
['id' => 2, 'event' => 'Profile updated'],
])
->addColumns([
NumberColumn::make('id')->numberCast('int')->visible(false),
TextColumn::make('event')->searchable()->sortable(),
]);

Return and render this table through Inertia as usual.

Arrays become Laravel collections. Eloquent collections remain in-memory snapshots; InertiaX does not turn them back into database queries.

Filters, search, and sorting process the full collection before pagination slices it. Use an Eloquent builder for large database datasets so those operations stay in SQL.

Plain rows default to an id key. A nonempty collection whose first item is an Eloquent model uses that model’s primary key. For custom model keys, set rowKey() explicitly if the collection can be empty. Declare the key as a column even when there are no rows.

Automatic columns need a resolvable Eloquent model. Use explicit columns for arrays, plain objects, and empty collections.

Built-in comparisons support both Eloquent and collections. Custom sorting, search, clause, and option callbacks must declare DataSourceKind::Collection and implement collection behavior. See Custom query behavior.