PHPackages                             digitalindoorsmen/laravel-actor-trails - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. digitalindoorsmen/laravel-actor-trails

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

digitalindoorsmen/laravel-actor-trails
======================================

Track created\_by, modified\_by, and deleted\_by as JSON objects in your Laravel models, with support for multiple guards and polymorphic actors.

v0.1.3(10mo ago)00[2 PRs](https://github.com/claybitner/laravel-actor-trails/pulls)MITPHPPHP ^8.3CI passing

Since Aug 26Pushed 7mo agoCompare

[ Source](https://github.com/claybitner/laravel-actor-trails)[ Packagist](https://packagist.org/packages/digitalindoorsmen/laravel-actor-trails)[ Docs](https://github.com/claybitner/laravel-actor-trails)[ GitHub Sponsors]()[ RSS](/packages/digitalindoorsmen-laravel-actor-trails/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (12)Versions (7)Used By (0)

Laravel Actor Trails
====================

[](#laravel-actor-trails)

Track `created_by`, `modified_by`, and `deleted_by` as JSON objects in your Laravel models, with support for multiple guards and polymorphic actors.

[![Latest Version on Packagist](https://camo.githubusercontent.com/75630926808f252434aef1229e7825f4a158f3d4c28ce7b798f7d93be6d40306/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6469676974616c696e646f6f72736d656e2f6c61726176656c2d6163746f722d747261696c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/digitalindoorsmen/laravel-actor-trails)[![GitHub Tests Action Status](https://camo.githubusercontent.com/78bbbd5470d6cda9fcb2885e7d76bb8596c301a7b56b36d4c3211be8559efb4c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6469676974616c696e646f6f72736d656e2f6c61726176656c2d6163746f722d747261696c732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/digitalindoorsmen/laravel-actor-trails/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/8340c4f184f20e89d1e3bc8eac4d9868a0af94243fe2be28ca7ec697a0906dcc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6469676974616c696e646f6f72736d656e2f6c61726176656c2d6163746f722d747261696c732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/digitalindoorsmen/laravel-actor-trails/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/7392fe06fdee5728fd1799566256e45a6a0a83ffccba4d07b573b703d62a8f68/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6469676974616c696e646f6f72736d656e2f6c61726176656c2d6163746f722d747261696c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/digitalindoorsmen/laravel-actor-trails)

---

✨ What It Does
--------------

[](#-what-it-does)

This package automatically tracks *who* created, modified, or deleted your Eloquent models.
Instead of just storing a raw `user_id`, it stores a **self‑contained JSON object** with details about the actor at the time of the action:

```
{
  "id": "16",
  "user_type": "Admin",
  "auth_table": "users",
  "display_name": "Kelly Montannavue"
}
```

This makes your audit trails:

- **Polymorphic** → works with multiple authenticatable models (`User`, `Admin`, `Member`, etc.)
- **Immutable** → keeps a snapshot of the actor’s display name and type, even if the user record changes later
- **Automatic** → hooks into Eloquent events (`creating`, `updating`, `deleting`)
- **Configurable** → choose which attributes to store in the JSON

---

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

[](#-installation)

You can install the package via composer:

```
composer require digitalindoorsmen/laravel-actor-trails
```

Publish the config file:

```
php artisan vendor:publish --tag="laravel-actor-trails-config"
```

Generate a migration for a specific table:

```
php artisan actor-trails:add posts
php artisan migrate
```

This will add `created_by`, `modified_by`, and `deleted_by` JSON columns to the `posts` table.

---

⚡ Usage
-------

[](#-usage)

Add the `HasActorTrails` trait to any model you want to track:

```
use DigitalIndoorsmen\LaravelActorTrails\Traits\HasActorTrails;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Post extends Model
{
    use HasActorTrails, SoftDeletes;

    protected $fillable = ['title', 'body'];
}
```

Now whenever you create, update, or soft delete a `Post`, the actor will be stored automatically:

```
$post = Post::create(['title' => 'Hello World']);

// Example created_by value:
[
  "id" => 1,
  "user_type" => "User",
  "auth_table" => "users",
  "display_name" => "Alice"
]
```

---

⚙️ Config
---------

[](#️-config)

The published config file (`config/actor-trails.php`) lets you define which attributes are stored:

```
return [
    'attributes' => [
        'id' => fn($user) => $user->getAuthIdentifier(),
        'user_type' => fn($user) => class_basename($user),
        'auth_table' => fn($user) => $user->getTable(),
        'display_name' => fn($user) => $user->name ?? $user->username ?? 'Unknown',
    ],
];
```

You can override this per model if needed.

---

🧪 Testing
---------

[](#-testing)

```
composer test
```

---

📜 Changelog
-----------

[](#-changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

---

🤝 Contributing
--------------

[](#-contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

---

🔒 Security
----------

[](#-security)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

---

👏 Credits
---------

[](#-credits)

- [Clay Bitner](https://github.com/claybitner)
- [All Contributors](../../contributors)

---

📄 License
---------

[](#-license)

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

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance59

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60.6% 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

4

Last Release

313d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/868070?v=4)[Clay Bitner](/maintainers/claybitner)[@claybitner](https://github.com/claybitner)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (376 commits)")[![mvdnbrk](https://avatars.githubusercontent.com/u/802681?v=4)](https://github.com/mvdnbrk "mvdnbrk (46 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (27 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (23 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (19 commits)")[![pforret](https://avatars.githubusercontent.com/u/474312?v=4)](https://github.com/pforret "pforret (16 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (14 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (10 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (10 commits)")[![crynobone](https://avatars.githubusercontent.com/u/172966?v=4)](https://github.com/crynobone "crynobone (8 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (8 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (7 commits)")[![irfanm96](https://avatars.githubusercontent.com/u/42065936?v=4)](https://github.com/irfanm96 "irfanm96 (5 commits)")[![thecaliskan](https://avatars.githubusercontent.com/u/13554944?v=4)](https://github.com/thecaliskan "thecaliskan (5 commits)")[![claybitner](https://avatars.githubusercontent.com/u/868070?v=4)](https://github.com/claybitner "claybitner (4 commits)")[![IGedeon](https://avatars.githubusercontent.com/u/694313?v=4)](https://github.com/IGedeon "IGedeon (4 commits)")[![abenerd](https://avatars.githubusercontent.com/u/7523903?v=4)](https://github.com/abenerd "abenerd (3 commits)")[![jessarcher](https://avatars.githubusercontent.com/u/4977161?v=4)](https://github.com/jessarcher "jessarcher (3 commits)")[![koossaayy](https://avatars.githubusercontent.com/u/6431084?v=4)](https://github.com/koossaayy "koossaayy (3 commits)")[![lloricode](https://avatars.githubusercontent.com/u/8251344?v=4)](https://github.com/lloricode "lloricode (3 commits)")

---

Tags

laravelBlameableAuditcreated\_byupdated\_bydeleted\_byDigitalIndoorsmenlaravel-actor-trails

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/digitalindoorsmen-laravel-actor-trails/health.svg)

```
[![Health](https://phpackages.com/badges/digitalindoorsmen-laravel-actor-trails/health.svg)](https://phpackages.com/packages/digitalindoorsmen-laravel-actor-trails)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k102.4M1.4k](/packages/spatie-laravel-permission)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M102](/packages/dedoc-scramble)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

811334.1k3](/packages/defstudio-telegraph)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

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