PHPackages                             temistocle1998/laravel-model-tracker - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. temistocle1998/laravel-model-tracker

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

temistocle1998/laravel-model-tracker
====================================

A Laravel package for tracking model changes, including old values, new values, and the user responsible for the changes

v1.2.2(1y ago)1219MITPHPPHP ^7.3|^8.0

Since Sep 19Pushed 1y ago2 watchersCompare

[ Source](https://github.com/temistocle1998/laravel-model-tracker)[ Packagist](https://packagist.org/packages/temistocle1998/laravel-model-tracker)[ RSS](/packages/temistocle1998-laravel-model-tracker/feed)WikiDiscussions master Synced 1mo ago

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

---

[![Laravel Logo](https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg)](https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg)

Laravel Model Tracker
=====================

[](#laravel-model-tracker)

[![Latest Stable Version](https://camo.githubusercontent.com/15afd65e6eb41974148aa7792e3448ea1b32a54d8aaa2ed2b4c930e9dd5849a3/68747470733a2f2f706f7365722e707567782e6f72672f74656d6973746f636c65313939382f6c61726176656c2d6d6f64656c2d747261636b65722f762f737461626c65)](https://packagist.org/packages/temistocle1998/laravel-model-tracker)[![Total Downloads](https://camo.githubusercontent.com/30decd2197009d2ee4cfd70c40e80fb70548207d4a2cc733936f896e8fbf4a98/68747470733a2f2f706f7365722e707567782e6f72672f74656d6973746f636c65313939382f6c61726176656c2d6d6f64656c2d747261636b65722f646f776e6c6f616473)](https://packagist.org/packages/temistocle1998/laravel-model-tracker)[![License](https://camo.githubusercontent.com/85245138950d35da209c56969dc0beea39d99dbe4048800d0eec61b7565ba5b8/68747470733a2f2f706f7365722e707567782e6f72672f74656d6973746f636c65313939382f6c61726176656c2d6d6f64656c2d747261636b65722f6c6963656e7365)](https://packagist.org/packages/temistocle1998/laravel-model-tracker)

A lightweight Laravel package to track changes in your models. Automatically logs all changes, including old values, new values, and the user responsible for the changes.

Features
--------

[](#features)

- Automatically tracks changes in any Eloquent model.
- Stores old and new values of updated fields.
- Logs the user who made the change (if authenticated).
- Provides easy integration with a simple trait.
- Configurable to exclude fields from tracking.
- Includes a migration to store logs in a `model_changes` table.

Requirements
------------

[](#requirements)

- Laravel 8.x or 9.x
- PHP 7.4 or higher

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

[](#installation)

1. **Install via Composer:**

    ```
    composer require temistocle1998/laravel-model-tracker
    ```
2. **Publish configuration and migration files:**

    ```
    php artisan vendor:publish --tag=tracker-config
    php artisan migrate
    ```
3. **Add the `TracksChanges` trait to your model:**

    In any model where you want to track changes, simply include the `TracksChanges` trait:

    ```
    use Tracker\Traits\TracksChanges;

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

Configuration
-------------

[](#configuration)

The package comes with a config file that can be customized to suit your needs. The configuration file can be found at `config/tracker.php`.

### Example Config:

[](#example-config)

```
return [
    'enabled' => true, // Enable or disable the tracking
    'exclude_fields' => ['password', 'remember_token'], // Fields you don't want to track
];
```

Usage
-----

[](#usage)

Once the package is set up, any changes made to the models using the `TracksChanges` trait will automatically be logged. The logs are stored in the `model_changes` table.

### Example of Change Logs

[](#example-of-change-logs)

When a model is updated, the following log is created in the `model_changes` table:

model\_typemodel\_iduser\_idchangescreated\_atApp\\Models\\Product12{"name": {"old\_value": "Old Name", "new\_value": "New Name"}}2023-01-01 12:00:00### Retrieving Model Changes

[](#retrieving-model-changes)

You can fetch model changes using the `ModelChange` model.

```
use Tracker\Models\ModelChange;

// Get all changes for a specific model
$changes = ModelChange::where('model_type', 'App\Models\Product')
                      ->where('model_id', $productId)
                      ->get();

// Display the changes
foreach ($changes as $change) {
    echo $change->changes;
}
```

### Displaying Changes in Your View

[](#displaying-changes-in-your-view)

You can also display the changes in your views:

```
@foreach ($product->changes as $change)
    Field: {{ $change['field'] }} | Old Value: {{ $change['old_value'] }} | New Value: {{ $change['new_value'] }}
@endforeach
```

Contributing
------------

[](#contributing)

Feel free to submit a pull request if you'd like to contribute to this package. All contributions are welcome!

License
-------

[](#license)

This package is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.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 ~1 days

Total

3

Last Release

598d ago

PHP version history (2 changes)1.0.0PHP ^7.4|^8.0

v1.2.1PHP ^7.3|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4de5286a53a99f0502fa8a398e1fd1c20e1955a4a17ad9ecb95e030076923976?d=identicon)[temistocle1998](/maintainers/temistocle1998)

---

Top Contributors

[![maestrobeye](https://avatars.githubusercontent.com/u/106831141?v=4)](https://github.com/maestrobeye "maestrobeye (11 commits)")[![temistocle1998](https://avatars.githubusercontent.com/u/59784401?v=4)](https://github.com/temistocle1998 "temistocle1998 (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/temistocle1998-laravel-model-tracker/health.svg)

```
[![Health](https://phpackages.com/badges/temistocle1998-laravel-model-tracker/health.svg)](https://phpackages.com/packages/temistocle1998-laravel-model-tracker)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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