PHPackages                             dvsoftsrl/laravel-attributechangelog - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. dvsoftsrl/laravel-attributechangelog

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

dvsoftsrl/laravel-attributechangelog
====================================

Attribute change logger for eloquent models

2.2.0(5mo ago)058[3 PRs](https://github.com/dvsoftsrl/laravel-attributechangelog/pulls)MITPHPPHP ^8.3CI passing

Since Nov 20Pushed 1mo agoCompare

[ Source](https://github.com/dvsoftsrl/laravel-attributechangelog)[ Packagist](https://packagist.org/packages/dvsoftsrl/laravel-attributechangelog)[ Docs](https://github.com/dvsoftsrl/laravel-attributechangelog)[ GitHub Sponsors]()[ RSS](/packages/dvsoftsrl-laravel-attributechangelog/feed)WikiDiscussions main Synced 1mo ago

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

Attribute change logger for eloquent models
===========================================

[](#attribute-change-logger-for-eloquent-models)

[![Latest Version on Packagist](https://camo.githubusercontent.com/cb46e7fae5c9db4b1dc565578990cfe62949758e77f50049a393085dd493a520/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6476736f667473726c2f6c61726176656c2d6174747269627574656368616e67656c6f672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dvsoftsrl/laravel-attributechangelog)[![GitHub Tests Action Status](https://camo.githubusercontent.com/4a5e591ed150af4b9869c071738b526f06563164d383d22a59da40d3dae59861/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6476736f667473726c2f6c61726176656c2d6174747269627574656368616e67656c6f672f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/dvsoftsrl/laravel-attributechangelog/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/0f7e332c70df70d8c4d70689d29f9dc033d8f8b4d1555f0738127e3f98f827ce/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6476736f667473726c2f6c61726176656c2d6174747269627574656368616e67656c6f672f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/dvsoftsrl/laravel-attributechangelog/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/e267dece82c5317ebd5b436cbc188764e2c54677f84bafde54098a9976bd1822/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6476736f667473726c2f6c61726176656c2d6174747269627574656368616e67656c6f672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dvsoftsrl/laravel-attributechangelog)

This package keeps track of every attribute that changes on an Eloquent model by storing one log row per attribute plus metadata about the acting model. It includes helpers to filter logs by attribute, subject, date, and causer so you can answer questions such as “when was `status` last changed on this model?” or “which models had `stage` updated yesterday?”

Features
--------

[](#features)

- Automatically listen to the `created`/`updated` events (customizable via `$recordEvents`)
- Persist each mutated attribute as a separate log entry with its `subject`, `causer`, `attribute`, and resolved `value`
- Support relation attributes and JSON-path segments (e.g. `order.customer.name`, `payload->meta.inner`)
- Expose fluent scopes for filtering by attribute, causer, date ranges, and subjects

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require dvsoftsrl/laravel-attributechangelog
```

You can publish and run the migrations with:

```
php artisan vendor:publish --provider="DvSoft\AttributeChangeLog\AttributeChangeLogServiceProvider" --tag="attributechangelog-migrations"
```

*Note*: The default migration assumes you are using integers for your model IDs. If you are using UUIDs, or some other format, adjust the format of the `subject_id` and `causer_id` fields in the published migration before continuing.

After publishing the migration you can create the `activity_log` table by running the migrations:

```
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --provider="DvSoft\AttributeChangeLog\AttributeChangeLogServiceProvider" --tag="attributechangelog-config"
```

This is the contents of the published config file:

```
return [
    'enabled' => env('ATTRIBUTE_CHANGE_LOGGER_ENABLED', true),
    'attribute_change_log_model' => \DvSoft\AttributeChangeLog\Models\AttributeChangeLog::class,
    'table_name' => env('ATTRIBUTE_CHANGE_TABLE_NAME', 'activity_log'),
    'database_connection' => env('ATTRIBUTE_CHANGE_DB_CONNECTION'),
];
```

You can override the log model (must implement `DvSoft\AttributeChangeLog\Contracts\AttributeChangeLog`) or change the table/connection before running the migrations.

Usage
-----

[](#usage)

```
use DvSoft\AttributeChangeLog\Traits\LogsAttributeChange;
use Illuminate\Database\Eloquent\Model;

class MyModel extends Model
{
    use LogsAttributeChange;

    protected $fillable = ['name', 'status'];
}
```

The trait listens for the configured events, writes one `AttributeChangeLog` row per attribute, and records the current value, root subject, optional JSON path, and optional `causer`. You can customize which attributes should be watched by overriding `$attributesToBeLogged`. When you record objects (for example, DTOs returned by custom casts) the log now keeps the original class plus a serialized payload so reading the entry returns the same object instance it stored.

```
$myModel = MyModel::find(1);
$myModel->status = 'published';
$myModel->save();

$lastStatusChange = $myModel->attributeChangeLogs()
    ->forAttribute('status')
    ->latest('created_at')
    ->first();

$yesterdayLogs = MyModel::editedAttributeOn('status', today()->subDay())->get();
```

Models that need to act as causers can use `DvSoft\AttributeChangeLog\Traits\CausesActivity` to expose the inverse morph relationship.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

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

Credits
-------

[](#credits)

- [Luca Dell'Orto](https://github.com/luca-dellorto)
- [Stefano Vergani](https://github.com/stefano-vergani)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance82

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

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

172d ago

Major Versions

1.1.0 → 2.2.02025-11-21

PHP version history (2 changes)1.0.0PHP ^8.4

1.1.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/2c86d96ea972a3b99a7b112e3c0bc63922fac14275b740177422496ab6cbf7e7?d=identicon)[luca-dellorto](/maintainers/luca-dellorto)

---

Top Contributors

[![luca-dellorto](https://avatars.githubusercontent.com/u/105433803?v=4)](https://github.com/luca-dellorto "luca-dellorto (13 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelDV Softlaravel-attributechangelog

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/dvsoftsrl-laravel-attributechangelog/health.svg)

```
[![Health](https://phpackages.com/badges/dvsoftsrl-laravel-attributechangelog/health.svg)](https://phpackages.com/packages/dvsoftsrl-laravel-attributechangelog)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[spatie/laravel-slack-alerts

Send a message to Slack

3212.6M4](/packages/spatie-laravel-slack-alerts)[keepsuit/laravel-opentelemetry

OpenTelemetry integration for laravel

142347.8k](/packages/keepsuit-laravel-opentelemetry)[spatie/laravel-error-share

Share your Laravel errors to Flare

43965.6k3](/packages/spatie-laravel-error-share)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[tapp/filament-maillog

Filament plugin to view outgoing mail

2952.6k1](/packages/tapp-filament-maillog)

PHPackages © 2026

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