Column API
Column classes live in InertiaX\Components\Table\Columns. Create a builder with
ColumnClass::make(string $key, ?string $label = null).
Common options
Section titled “Common options”| Method | Effect |
|---|---|
key(string $key) |
Set the source field key |
label(?string $label) |
Set the heading; an omitted label is derived from the key |
type(ColumnType|string $type) |
Set a built-in type or namespaced custom type |
sortable(bool $value = true) |
Permit sorting |
searchable(bool $value = true) |
Include in global search |
filterable(bool $value = true) |
Permit automatic filter generation |
copyable(bool $value = true) |
Show the copy control |
toggleable(bool $value = true) |
Include in the column picker |
visible(bool $value = true) |
Set initial visibility |
wrap(bool $value = true) |
Wrap displayed content |
truncate(?int $length) |
Limit displayed text length; 0 disables truncation; null or clearTruncate() removes the builder override |
filter($filter, ?string $label = null) |
Attach a filter object, builder, or key string |
meta(array|string $meta, mixed $value = null) |
Merge column metadata or set one metadata key |
ColumnType lives in InertiaX\Components\Table\Columns\Enums.
For defaults, see Defaults.
Clearing a truncation override restores inherited/default behavior; use truncate(0) to disable
truncation even when the table sets a length.
Hidden values are still sent to the browser; see Security.
Built-in value formats
Section titled “Built-in value formats”| Type | Options and defaults |
|---|---|
TextColumn |
Text value |
NumberColumn |
numberCast(string $cast) defaults to float; accepts int, integer, real, float, double, decimal |
BooleanColumn |
trueLabel(string) / falseLabel(string) default to True / False; trueIcon(string) / falseIcon(string) set icons |
DateColumn |
format(string) defaults to Y-m-d |
DateTimeColumn |
format(string) defaults to Y-m-d H:i:s |
TimeColumn |
format(string) defaults to H:i:s |
JsonColumn |
Preserves structured JSON; React formats its display |
BadgeColumn |
variant(Closure|array|string|Variant $variant, mixed $default = null) and icon(Closure|array|string $icon, mixed $default = null) |
Date, datetime, and time columns also support timezone(?string) and translate(bool = true).
The default timezone is the application timezone; translation is off by default and uses the
application locale when enabled. Formatting does not mutate a model-owned Carbon value.
Integer casts preserve large integers as decimal strings; decimal preserves a string value.
Invalid numeric values fail instead of becoming zero. Boolean labels and icons affect presentation;
the cell value remains Boolean.
The built-in renderer styles primary, secondary, success, danger, warning, and info
badge variants. These are also the cases in InertiaX\Components\Table\Columns\Enums\Variant.
Other variant strings are accepted but need application styling or a custom renderer.
Automatic columns
Section titled “Automatic columns”autoColumns() selects model fields in this order:
getTableFields([])when the model defines that method;- otherwise, a nonempty
$visiblelist; - otherwise,
$fillable.
It removes $hidden fields and exclusions from getTableExcludedFields() or tableExcludedFields,
then adds the row key if absent. An inferred row-key column is hidden and not toggleable.
Explicit columns with the same key take precedence. Explicit AutoColumn::make($key) infers only
that field and retains its chained options.
Inference needs an Eloquent model from the query or first collection row. Recognized model casts
win over schema types. An unrecognized cast falls back to text; without a cast, schema inference
runs, followed by timestamp-name heuristics (_at), then text. Schema inspection failures are
logged and use fallback inference.
Use explicit columns for parameterized or custom casts whose desired type is not inferred, and for arrays or empty collections. Review field exposure before using bulk inference.
Value transformers
Section titled “Value transformers”transformUsing($transformer) appends a transformer; repeated calls do not replace earlier stages.
mapAs(array $map, mixed $default = null) adds a mapping at priority 10.
| Method | Parameters |
|---|---|
addValueTransformer() |
$transformer, ?int $priority = null, ?string $name = null |
replaceValueTransformer() |
string $name, $transformer |
removeValueTransformer() |
string $name |
clearValueTransformers() |
None; also removes built-in transformations |
Transformers accept a closure, a ValueTransformer object, or its container-resolved class name.
The contract’s transform() receives the value, record, column, and table. Returning null
produces a null cell value. Transformations affect serialized cells, not query comparisons.
Lower priorities run first; the default priority is 100. Equal priorities retain declaration order. Replacing a named stage retains its priority and position. Duplicate names and missing replacement/removal targets fail.
Cell decorators
Section titled “Cell decorators”decorateUsing($decorator) appends a decorator. Parallel methods are addCellDecorator($decorator, ?int $priority = null, ?string $name = null), replaceCellDecorator(string $name, $decorator),
removeCellDecorator(string $name), and clearCellDecorators().
A closure or container-resolved CellDecorator receives the current CellPayload, record, column,
and table. It may mutate or replace the payload; returning null retains the current payload.
Ordering follows the same rules as transformers. Both contracts live in
InertiaX\Components\Table\Columns\Contracts.
Column meta() applies to every row; decorator metadata belongs to one cell. See
Custom columns for an example.
Query callbacks
Section titled “Query callbacks”sortUsing(?Closure $callback, DataSourceKind|string ...$sources) and
searchUsing(?Closure $callback, DataSourceKind|string ...$sources) customize query behavior.
Searchable columns whose type is not text require searchUsing(), including a TextColumn
with a custom type.
supportsSortSources(...$sources) and supportsSearchSources(...$sources) set the supported kinds
separately. DataSourceKind is in InertiaX\Components\Table\Enums.
See Custom query behavior for arguments and return contracts.