Actions
Tables carry two kinds of actions: row actions rendered per row, and bulk actions that operate on the selected rows. Both reuse Lattice’s Actions — the table only decides which actions to attach and with what context.
Row actions
Section titled “Row actions”Override actions() to return the components shown in each row’s action column. It receives the row
data, so you can build links and actions scoped to that record:
use Lattice\Lattice\Actions\Components\Action;use Lattice\Lattice\Core\Components\Link;
public function actions(array $row): array{ return [ Link::make('Edit')->href('/products/'.$row['id'].'/edit'), Action::use(ArchiveProductAction::class) ->context(['product_id' => $row['id']]), ];}Linknavigates, like any other link.Action::use()references an action class and runs it through the action endpoint. Pass per-row data with->context(); the action reads it back when it handles the request.
The row is a plain array of the serialized row values, so $row['id'] (and any other selected column)
is available to scope the action.
Bulk actions
Section titled “Bulk actions”Override bulkActions() to return actions that apply to a selection. When at least one row is
selected, the table shows a bulk action bar; running an action passes the selected rows to the action’s
handler.
use Lattice\Lattice\Actions\Components\BulkAction;
public function bulkActions(): array{ return [ BulkAction::use(ArchiveSelectedProductsAction::class), ];}The selection is resolved by the table’s data source — both an explicit set of checked rows and “select all matching”, which re-runs the current filters. With the Eloquent source this works with no extra code.
See Actions for defining the action and bulk-action classes themselves — including confirmation modals and the effects an action can return.