Skip to content

Callback context

Use $value for a scalar cell argument. A field named total_cents does not create a $total_cents callback argument:

NumberColumn::make('total_cents')
->transformUsing(fn (float $value): float => $value / 100);
TextColumn::make('customer_name')
->transformUsing(fn (string $value, Order $order): string => $value.' #'.$order->id);

The second example assumes Eloquent Order records and an imported application model. A typed record can have any parameter name. With array records, use array $record instead.

Parameters resolve by exact context name first, then by a unique matching object type, then by an explicitly bound Laravel service. A matching name with the wrong type fails; it does not fall through to another object or service. Unresolved optional parameters retain their defaults. Required scalar parameters must use an available name: there is no positional injection.

data(fn (...) => ...) Link to data
Available names definition, request, tableId
transformUsing() Link to transformUsing
Available names value, rawValue, currentValue, cell, cellPayload; record, model, item; column; table, serverExecution
decorateUsing() Link to decorateUsing
Available names Same names as transformers, but the value aliases contain a CellPayload
Badge variant() / icon() Link to Badge variant() / icon()
Available names value, record, model, column
sortUsing() Link to sortUsing
Available names source, query, data; column, direction, state, sorting
searchUsing() Link to searchUsing
Available names source, query, data; column, term, search, state
Select options() on Eloquent/collections Link to Select options() on Eloquent/collections
Available names filter, baseSource, source, request, state
Select options() on custom sources Link to Select options() on custom sources
Available names filter, source, request
Clause modifyUsing() Link to Clause modifyUsing()
Available names value, incomingValue, clause, filter, state
Clause validateUsing() Link to Clause validateUsing()
Available names value, normalizedValue, clause, filter, state
Clause applyUsing() Link to Clause applyUsing()
Available names source, query, column, key, value, clause, filter, state
Filter applyClauseUsing() Link to Filter applyClauseUsing()
Available names Clause apply names plus clauseKey, applyClause, table
CallbackSource fetch Link to CallbackSource fetch
Available names query, tableId
Catalog factories Link to Catalog factories
Available names host, hostClass, table, registrationId, registrationName, registrationOperation, registrationScope; filter when hosted by a Filter
Catalog modifiers Link to Catalog modifiers
Available names host, hostClass, table, features, columns / filters / clauses, modifierKey, modifierScope; filter when hosted by a Filter

Semicolons group aliases, not positional arguments. Transformer value aliases all refer to the current pipeline value, including rawValue. Badge callbacks have the smaller context shown above. In sort/search callbacks column is a Column object. In filter and clause apply callbacks it is the column the filter queries, as a string (see Automatic and attached filters), and key is the filter’s key. Select options for custom sources cannot request baseSource, query, or state: retrieval and validated state come later.

Only catalog factories and modifiers also permit container autowiring of unbound classes. For source-specific return contracts, see Custom query behavior, Clause API, and Source API.

View Markdown