Skip to main content

Overview

An audit log records who changed what and when. IlanaORM’s model events fire before and after every create, update, and delete — making it straightforward to capture a full change history.

1. Create the Audit Log Table

Already know your schema? Run npx ilana make:model AuditLog --migration to scaffold both files at once and skip straight to Step 3.

2. Create the AuditLog Model

3. Create an Auditable Observer

4. Create an Auditable Mixin

Rather than registering the observer on every model, create a base class:
Extend it on any model you want to audit:

5. Query the Audit Log

6. Add a Relationship Back to the Model

What You Get

Every create, update, and delete on an AuditableModel now writes a row like: