Skip to content

Relation actions

Related lists on the detail page have actions of their own, defined on the relation:

Method Shown Receives
headerActions([...]) above the related records the parent record; may have a form
recordActions([...]) in the rows of the related records the related record, the form data and the parent record; no form
detachable(...) a Remove row action see Remove
Relation::make('assignments')->resource(RoleAssignmentResource::class)->foreignKey('business_role_id')
->headerActions([
Action::make('assignPerson')->label('Assign person')->icon('person-plus')
->form(fn (Form $form) => $form->schema([
BelongsTo::make('person_id')->relationship(PersonModel::class, 'last_name')->searchable()->required(),
]))
->handle(fn ($role, array $data) => service('assignments')->assign($role, $data)),
])
->recordActions([
Action::make('extend')->icon('calendar-plus')->confirm('Extend by one year?')
->handle(fn ($assignment, array $data, $role) => service('assignments')->extend($assignment)),
]);
  • They are Action objects with the same options as record actions.
  • They require <parent slug>.update (with the policy of the parent) unless they name their own permission().
  • Record actions cannot have a form (LogicException); use confirm().
  • Every request checks again that the related record belongs to the parent.

All options of relations: Related records.