# Callback context

> Available callback arguments, name and type resolution, and service injection.

Source: https://docs.inertiax.dev/table/reference/callbacks/

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

```php
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.

## Parameter resolution

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.

## Available arguments

| Callback                                   | Available names                                                                                                                                    |
| ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `data(fn (...) => ...)`                    | `definition`, `request`, `tableId`                                                                                                                 |
| `transformUsing()`                         | `value`, `rawValue`, `currentValue`, `cell`, `cellPayload`; `record`, `model`, `item`; `column`; `table`, `serverExecution`                        |
| `decorateUsing()`                          | Same names as transformers, but the value aliases contain a `CellPayload`                                                                          |
| Badge `variant()` / `icon()`               | `value`, `record`, `model`, `column`                                                                                                               |
| `sortUsing()`                              | `source`, `query`, `data`; `column`, `direction`, `state`, `sorting`                                                                               |
| `searchUsing()`                            | `source`, `query`, `data`; `column`, `term`, `search`, `state`                                                                                     |
| Select `options()` on Eloquent/collections | `filter`, `baseSource`, `source`, `request`, `state`                                                                                               |
| Select `options()` on custom sources       | `filter`, `source`, `request`                                                                                                                      |
| Clause `modifyUsing()`                     | `value`, `incomingValue`, `clause`, `filter`, `state`                                                                                              |
| Clause `validateUsing()`                   | `value`, `normalizedValue`, `clause`, `filter`, `state`                                                                                            |
| Clause `applyUsing()`                      | `source`, `query`, `column`, `key`, `value`, `clause`, `filter`, `state`                                                                           |
| Filter `applyClauseUsing()`                | Clause apply names plus `clauseKey`, `applyClause`, `table`                                                                                        |
| `CallbackSource` fetch                     | `query`, `tableId`                                                                                                                                 |
| Catalog factories                          | `host`, `hostClass`, `table`, `registrationId`, `registrationName`, `registrationOperation`, `registrationScope`; `filter` when hosted by a Filter |
| Catalog modifiers                          | `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](https://docs.inertiax.dev/table/reference/filter/#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](https://docs.inertiax.dev/table/guide/query-callbacks/), [Clause API](https://docs.inertiax.dev/table/reference/clause/), and [Source API](https://docs.inertiax.dev/table/reference/source/).
