PHPackages                             czim/laravel-modelcomparer - 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. [Database &amp; ORM](/categories/database)
4. /
5. czim/laravel-modelcomparer

ActiveLibrary[Database &amp; ORM](/categories/database)

czim/laravel-modelcomparer
==========================

Performs a deep-nested comparison of a model's before/after state.

3.0.0(3y ago)24.4k↑16.7%MITPHPPHP ^8.1

Since Jan 29Pushed 3y ago1 watchersCompare

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

READMEChangelogDependencies (9)Versions (20)Used By (0)

Laravel Model Comparer
======================

[](#laravel-model-comparer)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a9ace3ce1f305ce00c4c18032a51850e10b158e763fdd33863e6b0d0f67992ed/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f637a696d2f6c61726176656c2d6d6f64656c636f6d70617265722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/czim/laravel-modelcomparer)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/c504c68d1075d7d41c39748e3fd516c4a5f8970f0e9b710fe116b263c0a7d8ef/68747470733a2f2f7472617669732d63692e6f72672f637a696d2f6c61726176656c2d6d6f64656c636f6d70617265722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/czim/laravel-modelcomparer)

This model comparer is a tool to make it easy to collect, log and report changes made to Eloquent models and their relations.

It's easy enough to compare model attributes before and after (or using `getDirty()`, during) updates for a single Eloquent model. Unfortunately, it is arduous to track updates while updating deeply nested relational model structures.

With this package, it's as simple as loading in the model before making changes, then loading it in again after. The comparer instance tracks the changes and offers the means to create concise changelogs.

Version Compatibility
---------------------

[](#version-compatibility)

LaravelPackagePHP Version5.3 and older0.95.4 to 5.71.45.81.55.8, 6.0+2.09.0+3.08.1+Install
-------

[](#install)

Via Composer

```
$ composer require czim/laravel-modelcomparer
```

If you're not using auto-discovery (or are installing a version older than 3.0), add the service provider in your `config/app.php` config.

```
    Czim\ModelComparer\ModelComparerServiceProvider::class,
```

Usage
-----

[](#usage)

1. Initialize a comparer instance
2. Before making changes, set the before state on the comparer by passing in the model
3. Make your changes to anything related to the model
4. Run the comparison by passing in the model again

The result is an comparison information object that stores all the changes and offers means for easy logging.

To Do
-----

[](#to-do)

- Add singleton with facade for easy tracking of changes

    - would use the model's class &amp; key to keep track of before states and allow setting after states
    - might even be done using an observer pattern
    - note: not recommended for long running processes, unless cleanup methods are used to keep memory load small
- Better change tracking for related models

    - Track before state index by model class &amp; key in the comparer
        - And, singleton should delegate this to currently active comparers
    - Track changes of a model when it is still via-via related before AND after (but for a different intermediary relation)
    - Allow manually 'loading in' before state for a to-be related model

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

[](#contributing)

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

Credits
-------

[](#credits)

- [Coen Zimmerman](https://github.com/czim)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 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 ~150 days

Recently: every ~137 days

Total

15

Last Release

1288d ago

Major Versions

0.9.3 → 1.4.02017-09-03

1.5.0 → 2.0.02019-09-21

2.0.7 → 3.0.02022-11-01

PHP version history (3 changes)0.9.1PHP &gt;=5.6.0

1.5.0PHP &gt;=7.1.3

3.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/1657b09521b6030fe32d864a493ded8b1dbbdf737ef3772135dfc123cea34767?d=identicon)[czim](/maintainers/czim)

---

Top Contributors

[![czim](https://avatars.githubusercontent.com/u/11831617?v=4)](https://github.com/czim "czim (10 commits)")

---

Tags

changelogeloquent-modelslaravellogginglogmodeleloquent

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/czim-laravel-modelcomparer/health.svg)

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

###  Alternatives

[spatie/laravel-translatable

A trait to make an Eloquent model hold translations

2.4k23.0M413](/packages/spatie-laravel-translatable)[panoscape/history

Eloquent model history tracking for Laravel

162130.3k](/packages/panoscape-history)[moloquent/moloquent

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)

120114.6k7](/packages/moloquent-moloquent)[elipzis/laravel-cacheable-model

Automatic query-based model cache for your Laravel app

15546.1k](/packages/elipzis-laravel-cacheable-model)[phaza/single-table-inheritance

Single Table Inheritance Trait

1515.8k](/packages/phaza-single-table-inheritance)

PHPackages © 2026

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