ScribeLog is an Eloquent model in HypathBel\ModelScribe\Models that represents a single audit log record written by a ModelScribe driver. Each row in the audit table corresponds to one ScribeLog instance and captures the event type, the actors involved, a JSON properties payload, contextual HTTP metadata, and optional grouping fields such as log name, tags, and a batch UUID.
Database Columns
The table name resolves dynamically viagetTable() (see below), defaulting to model_scribe_logs.
Casts
The following columns are automatically cast by Eloquent when reading from the database:Relationships
subject()
Returns the audited Eloquent model — the entity that was acted upon.causer()
Returns the Eloquent model representing the actor — typically the authenticated user who triggered the event.Query Scopes
All scopes follow Laravel’s local scope convention. Call them as static methods on the model class (without thescope prefix).
scope
Filters entries to those where
subject_type and subject_id match the given model. Use this to retrieve the full audit trail of a specific record.scope
Filters entries to those where
causer_type and causer_id match the given model. Use this to see every action a specific user has taken.scope
Filters entries to a specific event type string (e.g.
'updated', 'deleted').scope
Filters entries by
log_name. Useful when multiple model types write to named log channels.Accessors
These computed properties extract the two main sub-keys from theproperties JSON column, saving you from manually accessing the raw array.
array
Returns the model attributes after the event was applied, sourced from
$this->properties['attributes'] ?? []. Populated for created and updated events.array
Returns the model attributes before the event, sourced from
$this->properties['old'] ?? []. Populated for updated and deleted events.getTable() Override
ScribeLog overrides the default Eloquent getTable() method to support dynamic table-name resolution:
table property has been set explicitly on the model instance, that value takes precedence. Otherwise, the table name is read from config('model-scribe.drivers.database.table'), falling back to 'model_scribe_logs'. This means you can change the audit table name in your configuration without touching any model classes or query code.
Putting It All Together
The
properties column stores a raw JSON blob. Always access attribute snapshots through the new_attributes and old_attributes accessors rather than indexing into $log->properties directly — the accessors provide safe null-coalescing defaults.