Skip to main content

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.

ModelScribe brings powerful, driver-based audit logging to your Laravel application. Add one trait to any Eloquent model and every created, updated, and deleted event is automatically captured — including a full before/after diff of the changed attributes, who made the change, and where the request came from.

Installation

Install via Composer and publish the config and migrations in minutes.

Quickstart

Add the HasAuditLog trait and start recording model changes right away.

Drivers

Route logs to a database table, a log file, or fan out to both simultaneously.

API Reference

Explore the full PHP API: trait properties, facade methods, and model scopes.

Why ModelScribe?

Most audit log packages give you one destination. ModelScribe is built around a driver architecture — the same entry can flow to a database table, a Laravel log channel, or any custom target you register. Each model can independently choose its driver and log table, making it straightforward to keep orders and invoices in separate tables or separate database connections.

Trait-Based

One line of code activates auditing on any Eloquent model. No observers to register manually.

Multi-Table Routing

Map each model to its own log table or database connection using named stores.

Deep Diffing

Every updated event records the exact attributes that changed, old value and new.

Rich Context

Automatically captures URL, IP address, User Agent, and the authenticated causer.

Flexible Retention

Choose permanent storage, time-based expiry, or a rolling window of N records.

Custom Drivers

Register your own driver (ELK, webhooks, etc.) with a single extend() call.

Getting Started

1

Install the package

Pull ModelScribe into your project via Composer:
composer require hypathbel/model-scribe
2

Publish and migrate

Publish the config file and database migration, then run migrations:
php artisan vendor:publish --tag="model-scribe-config"
php artisan vendor:publish --tag="model-scribe-migrations"
php artisan migrate
3

Add the trait

Drop HasAuditLog onto any Eloquent model to start recording changes:
use HypathBel\ModelScribe\Traits\HasAuditLog;

class Order extends Model
{
    use HasAuditLog;
}
4

Query your logs

Use the ScribeLog model and its built-in scopes to read audit records:
use HypathBel\ModelScribe\Models\ScribeLog;

$logs = ScribeLog::forSubject($order)->latest()->get();

Build docs developers (and LLMs) love