Documentation Index
Fetch the complete documentation index at: https://mintlify.com/HypathStack/model-scribe/llms.txt
Use this file to discover all available pages before exploring further.
ScribeEvent is a PHP 8.1+ backed string enum in HypathBel\ModelScribe\Enums that represents the type of audit event recorded by ModelScribe. Every log entry — whether written automatically by the observer or manually via the facade — carries one of these six event types. Being a backed enum, each case has a string value that is stored in the event column of the audit table and can round-trip cleanly between PHP and the database.
Enum Definition
Cases
Triggered by the Eloquent
retrieved event, which fires every time an existing model is fetched from the database. This case is not included in the default $auditEvents array on HasAuditLog.Use it deliberately and sparingly — see the tip at the bottom of this page.Triggered when a new model record is inserted into the database. This is one of the three default events in
$auditEvents. The properties.attributes snapshot contains the full set of attributes written at creation time.Triggered when an existing model record is saved with changed attributes. This is one of the three default events in
$auditEvents. The properties payload contains both old (values before the save) and attributes (values after the save), making it straightforward to compute a diff.Triggered when a model record is removed from the database (or soft-deleted when the model uses
SoftDeletes). This is one of the three default events in $auditEvents. The properties.old snapshot captures the attribute state immediately before deletion.Triggered when a soft-deleted model is restored via
$model->restore(). Not included in the default $auditEvents array — add 'restored' to the array explicitly on any model that uses SoftDeletes and requires restore tracking.A free-form event type for manual logging via
ModelScribe::log(). Use this for application-level events that have no Eloquent lifecycle equivalent — logins, exports, batch jobs, permission grants, and so on. ScribeEvent::Custom is only ever written by explicit calls to the facade; the observer never emits it automatically.Quick-Reference Table
| Case | String value | Emitted by observer | Default in $auditEvents |
|---|---|---|---|
Retrieved | 'retrieved' | Yes (if enabled) | No |
Created | 'created' | Yes | Yes |
Updated | 'updated' | Yes | Yes |
Deleted | 'deleted' | Yes | Yes |
Restored | 'restored' | Yes (if enabled) | No |
Custom | 'custom' | No | No |
Usage with the Facade
Both the enum case and its raw string value are accepted byModelScribe::log().
Filtering query results by event
Because the string value is stored verbatim in theevent column, you can use both forms when querying ScribeLog:
ScribeEvent::from(string $value) is used internally by ModelScribe::log() when you pass a raw string as the $event argument. If the string does not match any enum case, PHP throws a \ValueError. Always use a recognised value — or pass the enum case directly — to avoid this.