PHPackages                             hypathbel/model-scribe - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. hypathbel/model-scribe

ActiveLibrary

hypathbel/model-scribe
======================

A driver-based Eloquent audit log package for Laravel — log model activity to database, files, or custom targets.

v1.0.0(2d ago)01↓50%MITPHPPHP ^8.3CI passing

Since Apr 3Pushed yesterdayCompare

[ Source](https://github.com/HypathStack/model-scribe)[ Packagist](https://packagist.org/packages/hypathbel/model-scribe)[ Docs](https://github.com/hypathbel/model-scribe)[ GitHub Sponsors](https://github.com/:vendor_name)[ RSS](/packages/hypathbel-model-scribe/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (13)Versions (5)Used By (0)

ModelScribe ✍️
==============

[](#modelscribe-️)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0b043649bd1734ec1471036f2ea34a0d52e5d9556ac29fc59a3affe3a7ef34da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68797061746862656c2f6d6f64656c2d7363726962652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hypathbel/model-scribe)[![Total Downloads](https://camo.githubusercontent.com/86054e7f201e5d51dba65581bc4ab793a4ea6e53d19200047cffb122d0a84f5d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68797061746862656c2f6d6f64656c2d7363726962652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hypathbel/model-scribe)[![License](https://camo.githubusercontent.com/665a14e292e3de359479665070e459ce7c2427dec19205b0cbc4f42f0c677c18/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f68797061746862656c2f6d6f64656c2d7363726962652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hypathbel/model-scribe)

**ModelScribe** is a powerful, driver-based audit log package for Laravel. It allows you to effortlessly record every change in your Eloquent models and route them exactly where they need to go: a database table, a flat file, multiple targets simultaneously (stack), or custom targets like ELK or Webhooks.

Unlike other packages, ModelScribe excels at **multi-table routing**, allowing you to logically separate logs for different business domains into different database tables or even different connections.

---

✨ Features
----------

[](#-features)

- **Eloquent Integration**: Simple trait-based setup.
- **Multi-Target Drivers**: Support for `database`, `file`, and `stack` (log to multiple places at once).
- **Multi-Table Routing**: Map different models to different log tables or database connections.
- **Deep Diffing**: Records `old` vs `new` attributes automatically.
- **Customizable Retention**: Choose between `permanent`, `days`-based, or `rotating` (keep N records per table).
- **Rich Context**: Automatically captures URL, IP Address, User Agent, and the authenticated "causer".
- **Batching**: Group related operations with a unique `batch_uuid`.
- **Developer Friendly**: Clean API, Facades, and a prune command.

---

🚀 Installation
--------------

[](#-installation)

Install the package via composer:

```
composer require hypathbel/model-scribe
```

Publish the configuration and migrations:

```
php artisan vendor:publish --tag="model-scribe-config"
php artisan vendor:publish --tag="model-scribe-migrations"
```

Run the migrations:

```
php artisan migrate
```

---

⚙️ Configuration
----------------

[](#️-configuration)

The `config/model-scribe.php` file allows you to define your drivers and their behavior.

### Database Driver &amp; Multi-Table Stores

[](#database-driver--multi-table-stores)

You can define multiple "stores" within the database driver. This is perfect for high-traffic apps that want to keep `order` logs and `invoice` logs in separate tables.

```
'drivers' => [
    'database' => [
        'driver'     => 'database',
        'table'      => 'model_scribe_logs', // Default table
        'stores' => [
            'invoices' => [
                'table'      => 'invoice_logs',
                'connection' => 'audit_db', // Optional: use a different connection
            ],
            'orders' => [
                'table' => 'order_logs',
            ],
        ],
        'retention' => [
            'type' => 'days',
            'days' => 90,
        ],
    ],
],
```

Generate a migration for a new store:

```
php artisan model-scribe:make-table invoices
```

---

🛠️ Usage
--------

[](#️-usage)

### 1. Basic Auditing

[](#1-basic-auditing)

Add the `HasAuditLog` trait to your Eloquent model.

```
use HypathBel\ModelScribe\Traits\HasAuditLog;

class Product extends Model
{
    use HasAuditLog;
}
```

### 2. Customizing Events and Attributes

[](#2-customizing-events-and-attributes)

By default, ModelScribe logs `created`, `updated`, and `deleted`. You can customize this per model.

```
class Order extends Model
{
    use HasAuditLog;

    // Only log specific events
    protected array $auditEvents = ['created', 'updated'];

    // Limit which attributes are recorded per event
    protected array $auditAttributes = [
        'updated' => ['status', 'total_price', 'shipping_address'],
    ];

    // Route to a specific store/table
    protected string $auditLogName = 'orders';

    // Add searchable tags to every log entry
    protected array $auditTags = ['warehouse-A', 'priority-high'];
}
```

### 3. Manual Logging

[](#3-manual-logging)

Sometimes you want to log actions that aren't tied to an Eloquent lifecycle.

```
use HypathBel\ModelScribe\Facades\ModelScribe;
use HypathBel\ModelScribe\Enums\ScribeEvent;

ModelScribe::log(
    event: ScribeEvent::Custom,
    logName: 'system',
    description: 'User initiated a bulk export',
    properties: ['format' => 'csv', 'rows' => 1200],
    tags: ['export']
);
```

---

🧹 Maintenance (Pruning)
-----------------------

[](#-maintenance-pruning)

Keep your log tables lean. ModelScribe includes a prune command that respects the retention policy defined in your config.

```
# Prune the default driver
php artisan model-scribe:prune

# Prune a specific driver
php artisan model-scribe:prune --driver=file
```

---

🧪 Testing
---------

[](#-testing)

```
composer test
```

---

📜 License
---------

[](#-license)

The MIT License (MIT). See [License File](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/90e86c7a5780ecc548ffe5f7b7a610dd6f53b42462bb3fa1c45ca61a9c3a3971?d=identicon)[hypathbel](/maintainers/hypathbel)

---

Top Contributors

[![HypathBel](https://avatars.githubusercontent.com/u/95283167?v=4)](https://github.com/HypathBel "HypathBel (12 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

laravelAuditactivity-loghypathbelmodel-scribe

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/hypathbel-model-scribe/health.svg)

```
[![Health](https://phpackages.com/badges/hypathbel-model-scribe/health.svg)](https://phpackages.com/packages/hypathbel-model-scribe)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

13.0k107.5M1.6k](/packages/spatie-laravel-permission)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.2k12.6M140](/packages/dedoc-scramble)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k5.4M50](/packages/spatie-laravel-pdf)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

818355.4k3](/packages/defstudio-telegraph)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3915.5k](/packages/rawilk-profile-filament-plugin)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

46273.9k](/packages/harris21-laravel-fuse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
