Skip to content

History

The detail page shows the changes of the record from the audit log: who changed what and when, with old and new values.

Users with <slug>.history (and the policy of the record). Override showsHistory() to hide the history of a resource completely:

public function showsHistory(): bool
{
return false;
}
  • Creation, changes and deletion of the record (record.created, record.updated, record.deleted), with the changed fields only.
  • Values are formatted with the form fields: titles for BelongsTo, labels for options, locale formatted numbers, see Forms.
  • Columns that are not in the form and look like references (*_id) are listed as “changed” without their value, so internal ids never reach the browser. Sensitive fields are masked in the audit log anyway ([masked]), see Data rules.

Custom audit events with the record as subject appear as well:

service('auditLogger')->record('order.approved', 'orders', Uuid::fromString($order->uuid));

The subject type is the audit subject of the model (by default the table name). Translate event names in Language/<locale>/Anvil.php under history.events (dots replaced by underscores), e.g. order_approved.