TheDocumentation 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.
ModelScribe facade provides a static interface to the underlying HypathBel\ModelScribe\ModelScribe class, which is bound to the Laravel service container. Use it to log arbitrary events outside of Eloquent observers, to trigger driver-level retention pruning, or to access the DriverManager for registering custom drivers.
Methods
log()
Manually record an audit entry without an Eloquent model lifecycle event. Useful for application-level events such as logins, exports, scheduled jobs, or anything that falls outside the standardcreated / updated / deleted lifecycle.
The event type to record. Accepts a
ScribeEvent enum instance (e.g. ScribeEvent::Custom) or its string value (e.g. 'custom'). When a string is passed, ScribeEvent::from() is used internally — passing an unrecognised string will throw a ValueError.The routing key written to the
log_name column. Use this to group related entries (e.g. 'system', 'orders') and query them later with ScribeLog::inLog().A human-readable sentence describing what happened. Stored in the
description column and intended for display in audit UIs or log viewers.The Eloquent model that was acted upon (the “what”). Stored as a polymorphic morph pair (
subject_type / subject_id) on the log record.The actor who triggered the event (the “who”) — typically an
App\Models\User. When logging through the Eloquent observer, this defaults to Auth::user(). For manual log() calls, pass the causer explicitly when one exists.Arbitrary key-value data stored in the
properties JSON column. For change-tracking entries, the observer populates ['old' => [...], 'attributes' => [...]]. For custom entries, you may store any structure here.An array of string tags written to the
tags JSON column. Tags enable free-form filtering of entries across log names and event types.Override which driver handles this specific entry. When
null, the globally-configured default driver (from config('model-scribe.default')) is used.prune()
Trigger retention cleanup on a driver, deleting stale records according to its configured retention policy. Returns the number of records removed.The driver to prune. Pass a named driver key (e.g.
'database') to target a specific driver, or leave as null to prune the global default driver. Drivers that do not manage persistent storage (such as webhook drivers) return 0.getDriverManager()
Return the underlyingDriverManager instance. Use this to register custom third-party drivers via extend(), or to flush the resolved driver cache during testing.
Usage Examples
Logging a manual event
Logging with a string event value
Routing to a specific driver
Pruning stale records
Registering a custom driver
The
log() method constructs an immutable LogEntry DTO internally and passes it to the resolved driver. The $causer you supply is stored as-is — unlike the observer, ModelScribe::log() does not automatically fall back to Auth::user(). Always pass an explicit causer when one is available.