Skip to content

Columns

Defining Columns

php
use Forjed\InertiaTable\Column;

Column::make('name', 'Name')         // visible column
Column::data('id')                    // hidden data-only column
Column::data('can_edit', fn ($m) => $m->canEdit())  // computed hidden column

Fluent Methods

php
Column::make('name', 'Name')
    ->sortable()                     // allow sorting
    ->hidden()                       // include data but don't render
    ->accessor('users.name')         // override DB column for sorting/extraction
    ->value(fn ($m) => strtoupper($m->name))  // custom value resolver

Display Modifiers

Display modifiers configure how a cell is rendered. Chain multiple modifiers to compose renderers in a single cell:

php
Column::make('name', 'Name')
    ->icon('user_icon')    // renders icon first
    ->text()               // then text beside it
ModifierDescription
->text()Plain text
->badge($value, $colorField, $variant, $tooltip)Styled badge
->date($value, $format)Formatted date
->link($route, $params, $value, $prefetch)Inertia link
->copyable()Click-to-copy
->icon($icon)Named icon from registry
->component($name)Custom component from registry
->enum()Enum integration (badge with getText/getColor)

Value Convention

All modifiers accepting a $value parameter follow this convention:

TypeBehaviour
nullUses the column's own value
stringReferences another field from the row
ClosureComputed server-side - receives the model, result added to row
php
Column::make('status', 'Status')->badge()                      // column's own value
Column::make('status', 'Status')->badge('status_label')        // different field
Column::make('status', 'Status')->badge(fn ($m) => $m->label)  // server-computed

Hidden Data Columns

Pass data to the frontend without rendering a visible column:

php
Column::data('id'),
Column::data('can_delete', fn ($m) => $m->canBeDeleted()),
Column::data('project_id'),

Hidden column data is accessible in actions, cell overrides, onRowClick, etc:

tsx
<InertiaTable
    tableData={servers}
    actions={(row) => (
        // row.id and row.can_delete are available here
        row.can_delete && <button onClick={() => deleteServer(row.id)}>Delete</button>
    )}
/>
vue
<!-- Coming soon -->