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.
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.
| Column | Type | Nullable | Default | Description |
|---|---|---|---|---|
id | bigint | No | auto-increment | Primary key |
log_name | string | No | 'default' | Routing / grouping key set by $auditLogName |
event | string | No | — | The event type; one of the ScribeEvent string values |
description | text | Yes | null | Optional human-readable description of the event |
causer_type | string | Yes | null | Polymorphic morph type for the acting model |
causer_id | bigint / string | Yes | null | Polymorphic morph ID for the acting model |
subject_type | string | Yes | null | Polymorphic morph type for the audited model |
subject_id | bigint / string | Yes | null | Polymorphic morph ID for the audited model |
properties | json | Yes | null | Attribute snapshot; contains old and attributes keys |
url | text | Yes | null | Full URL of the HTTP request that triggered the event |
ip_address | inet | Yes | null | Client IP address at the time of the event |
user_agent | string | Yes | null | Client User-Agent string at the time of the event |
batch_uuid | uuid | Yes | null | Groups related entries created in the same request cycle |
tags | json | Yes | null | Array of string tags |
created_at | timestamp | No | — | Standard Eloquent timestamp |
updated_at | timestamp | No | — | Standard Eloquent timestamp |
Casts
The following columns are automatically cast by Eloquent when reading from the database:| Property | Cast | Notes |
|---|---|---|
properties | array | Deserialized from JSON; contains 'old' and 'attributes' sub-keys |
tags | array | Deserialized from JSON; an array of strings |
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).
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.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.Filters entries to a specific event type string (e.g.
'updated', 'deleted').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.
Returns the model attributes after the event was applied, sourced from
$this->properties['attributes'] ?? []. Populated for created and updated events.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.