PHPackages                             audunru/model-history - 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. audunru/model-history

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

audunru/model-history
=====================

Log changes to Laravel models

v4.0.0(1mo ago)03.0k↑16.7%MITPHPPHP ^8.3CI passing

Since Sep 19Pushed 1mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (20)Versions (29)Used By (0)

Track changes to Laravel models
===============================

[](#track-changes-to-laravel-models)

[![Build Status](https://github.com/audunru/model-history/actions/workflows/validate.yml/badge.svg)](https://github.com/audunru/model-history/actions/workflows/validate.yml)[![Coverage Status](https://camo.githubusercontent.com/7f72d43ea80496f41046e3850820433b800cb4791a08f5fbf44dcb2145ffe30f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f617564756e72752f6d6f64656c2d686973746f72792f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/audunru/model-history?branch=main)

Keep a record of changes to models in your application. If a user changes the name of a product from A to B, that change will be stored in a `Change` model and stored in your database. Only the changed attributes are stored. You can then use this to retrieve the model's history, including which user made the change.

Installation
============

[](#installation)

Step 1: Install with Composer
-----------------------------

[](#step-1-install-with-composer)

```
composer require audunru/model-history
```

Step 2: Publish and run migrations
----------------------------------

[](#step-2-publish-and-run-migrations)

Note: Changes are stored in a table called `history`. You can change this in the configuration, but you will have to publish the configuration before publishing and running the migrations.

```
php artisan vendor:publish --tag=model-history-migrations
php artisan migrate
```

Step 3: Add traits to your models
---------------------------------

[](#step-3-add-traits-to-your-models)

Add the `MakesChanges` trait to your `User` model:

```
namespace App\Models;

use audunru\ModelHistory\Traits\MakesChanges;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use MakesChanges;
```

Add the `HasHistory` trait to any model where you want to track changes:

```
namespace App\Models;

use audunru\ModelHistory\Traits\HasHistory;
use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    use HasHistory;
```

Step 4: Retrieve model changes
------------------------------

[](#step-4-retrieve-model-changes)

Assuming that you've added the `HasHistory` trait to a model named `Product`, you can retrieve the changes like this:

```
$product = Product::create([
    'description' => 'Old description',
]);

$product->update([
    'description' => 'New description',
]);

dump($product->changes);
```

Configuration
=============

[](#configuration)

Publish the configuration file by running:

```
php artisan vendor:publish --tag=model-history-config
```

Available options:

```
    /*
     * Table where the "Change" model will be stored
     */
    'history_table_name' => 'history',
    /*
     * Eager load the change model's owner
     */
    'eager_load_owner' => true,
    /*
     * Eager load the change model's model
     */
    'eager_load_model' => false,
    /*
     * Date format used when returning the Change model as JSON
     */
    'date_format' => 'Y-m-d H:i:s',
```

Development
===========

[](#development)

Testing
-------

[](#testing)

Run tests:

```
composer test
```

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance90

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~78 days

Recently: every ~43 days

Total

22

Last Release

56d ago

Major Versions

v0.3.0 → v1.0.02023-07-18

v1.0.1 → v2.0.02024-04-07

v2.1.5 → v3.0.02025-03-16

v3.0.5 → v13.x-dev2026-03-24

PHP version history (4 changes)v0.1.0PHP ^8.0

v1.0.0PHP ^8.1

v2.0.0PHP ^8.2

v13.x-devPHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/444043228e007e4f695d18a30380b811fb60077138f7c46f111f45a1b98e2f1c?d=identicon)[audunru](/maintainers/audunru)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (52 commits)")[![audunru](https://avatars.githubusercontent.com/u/5163790?v=4)](https://github.com/audunru "audunru (36 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (14 commits)")[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (2 commits)")

---

Tags

loglaravelmodelAudithistorychanges

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/audunru-model-history/health.svg)

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

###  Alternatives

[owen-it/laravel-auditing

Audit changes of your Eloquent models in Laravel

3.4k33.0M95](/packages/owen-it-laravel-auditing)[altek/accountant

The auditing &amp; accountability package for Laravel's Eloquent ORM.

92954.3k4](/packages/altek-accountant)[betapeak/laravel-auditing-filesystem

A filesystem driver for the owen-it/laravel-auditing package. Allows storage of the audits in CSV files, across all registered Laravel disks.

166.5k](/packages/betapeak-laravel-auditing-filesystem)

PHPackages © 2026

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