PHPackages                             carlosdev/model-change-logger - 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. carlosdev/model-change-logger

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

carlosdev/model-change-logger
=============================

Laravel package to log create, update, and delete events in Eloquent models with JSON snapshots and user attribution.

v2.0.0(1mo ago)411MITPHPPHP ^8.0CI failing

Since Mar 23Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Charlie100901/model-change-logger)[ Packagist](https://packagist.org/packages/carlosdev/model-change-logger)[ RSS](/packages/carlosdev-model-change-logger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (6)Used By (0)

Model Change Logger
===================

[](#model-change-logger)

[![CI](https://github.com/carlosdev/model-change-logger/actions/workflows/ci.yml/badge.svg)](https://github.com/carlosdev/model-change-logger/actions/workflows/ci.yml/badge.svg)

[Leer en Espanol](README.es.md)

**Laravel library for recording changes (create, update, delete) in models.**
Records JSON snapshots of changes, the responsible user, and the date of the change in a database table.

---

📦 Installation
--------------

[](#-installation)

Add the package to your project via Composer:

```
composer require carlosdev/model-change-logger
```

Make sure you have PHP 8.0+ and Laravel 10 - 13.

🔧 Configuration
---------------

[](#-configuration)

Publish and run migrations:

```
php artisan migrate
```

Use the trait in the model you want to audit:

```
use CarlosDev\ModelChangeLogger\Traits\TracksChanges;

class JobOffer extends Model
{
    use TracksChanges;
}
```

(Optional) Audit only specific attributes: If you want to record only certain attributes, define the $auditFields property in your model:

```
protected array $auditFields = ['job_offer_status_id', 'title'];
```

🧪 Examples
----------

[](#-examples)

### Create

[](#create)

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

Recorded values:

```
{
    "event": "created",
    "old_value": null,
    "new_value": {
        "title": "Hello World",
        "content": "First post"
    }
}
```

### Update

[](#update)

```
$post->update(['title' => 'New title']);
```

Recorded values:

```
{
    "event": "updated",
    "old_value": {
        "title": "Hello World"
    },
    "new_value": {
        "title": "New title"
    }
}
```

### Delete

[](#delete)

```
$post->delete();
```

Recorded values:

```
{
    "event": "deleted",
    "old_value": {
        "title": "New title",
        "content": "First post"
    },
    "new_value": null
}
```

🧠 What does it record?
----------------------

[](#-what-does-it-record)

- JSON payload with old/new values for changed attributes on update().
- JSON payload with all tracked attributes on create.
- Deletions (delete and forceDelete), saving a JSON snapshot of tracked attributes in old\_value.
- Responsible user (Auth::id()).
- Affected model and ID.
- Date and time of the change.

📄 Structure of the model\_changes table
---------------------------------------

[](#-structure-of-the-model_changes-table)

ColumnDescriptionmodel\_typeClass of the affected model (App\\Models\\X)model\_idID of the modified modelold\_valuePrevious valuenew\_valueNew valueuser\_idID of the user who made the changeeventType of event (updated, deleted, etc.)changed\_atDate and time of the change✅ Compatibility
---------------

[](#-compatibility)

- PHP: &gt;= 8.0
- Laravel: ^10.0 - ^13.0

📬 Contributions
---------------

[](#-contributions)

Suggestions, improvements, and pull requests are welcome! 🚀

This package is designed for projects that require change traceability without depending on complex auditing packages.

📄 License
---------

[](#-license)

MIT © CarlosDev

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance90

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~93 days

Total

5

Last Release

49d ago

Major Versions

v1.0.3 → v2.0.02026-03-31

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c50358409807792f3993b54efe23cbbf8a9ac8e08bc0f7f612cb7f2cf30067a?d=identicon)[carlosdev](/maintainers/carlosdev)

---

Top Contributors

[![carlosdlrb-dev](https://avatars.githubusercontent.com/u/158684700?v=4)](https://github.com/carlosdlrb-dev "carlosdlrb-dev (27 commits)")

---

Tags

laravelAuditloggeractivity-logaudit-logactivity loggerchange-trackinglaravel auditmodel-changeslaravel-model-auditchange loggermodel loggertracks changeseloquent auditeloquent changeschange logmodel change loggermodel change trackinglaravel model changeeloquent model changeseloquent model auditeloquent observer

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/carlosdev-model-change-logger/health.svg)

```
[![Health](https://phpackages.com/badges/carlosdev-model-change-logger/health.svg)](https://phpackages.com/packages/carlosdev-model-change-logger)
```

###  Alternatives

[marvinlabs/laravel-discord-logger

Logging to a discord channel in Laravel

2081.1M2](/packages/marvinlabs-laravel-discord-logger)[muhammadsadeeq/laravel-activitylog-ui

A beautiful, modern UI for Spatie's Activity Log with advanced filtering, analytics, and real-time features.

17510.1k](/packages/muhammadsadeeq-laravel-activitylog-ui)[alizharb/filament-activity-log

A powerful, feature-rich activity logging solution for FilamentPHP v4 &amp; v5 with timeline views, dashboard widgets, and revert actions.

2326.6k](/packages/alizharb-filament-activity-log)

PHPackages © 2026

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