ModelScribe automatically resolves
Auth::user() as the causer for every log entry created during an authenticated request. No extra configuration is required — the authenticated user is captured and stored as a polymorphic causer relationship on each entry.Step-by-Step Walkthrough
1
Add HasAuditLog to a model
Import the
HasAuditLog trait and add it to any Eloquent model. That single line is all the setup required — ModelScribe will automatically observe created, updated, and deleted events from this point on.2
Trigger audited Eloquent operations
Perform ordinary Eloquent operations on your model — ModelScribe intercepts the lifecycle events and writes a log entry for each one automatically.
3
Query the log entries
Retrieve the audit trail for your model using the
ScribeLog model’s forSubject() scope. This returns a standard Eloquent query builder, so you can chain any additional constraints or ordering you need.4
Inspect a log record
A typical log entry for an
updated event looks like this. The properties column holds an old snapshot of the values before the change and an attributes snapshot of the values after — giving you a complete, reversible diff.