{"id":22125726,"url":"https://github.com/czim/laravel-modelcomparer","last_synced_at":"2025-10-15T22:47:59.998Z","repository":{"id":56960923,"uuid":"79841183","full_name":"czim/laravel-modelcomparer","owner":"czim","description":"A tool for making change logs for Eloquent models and their relations","archived":false,"fork":false,"pushed_at":"2022-11-01T16:37:54.000Z","size":132,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-18T07:49:34.828Z","etag":null,"topics":["changelog","eloquent-models","laravel","logging"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/czim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-23T19:47:21.000Z","updated_at":"2024-02-21T17:10:37.000Z","dependencies_parsed_at":"2022-08-21T09:20:51.657Z","dependency_job_id":null,"html_url":"https://github.com/czim/laravel-modelcomparer","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czim%2Flaravel-modelcomparer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czim%2Flaravel-modelcomparer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czim%2Flaravel-modelcomparer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czim%2Flaravel-modelcomparer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/czim","download_url":"https://codeload.github.com/czim/laravel-modelcomparer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227594868,"owners_count":17791202,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["changelog","eloquent-models","laravel","logging"],"created_at":"2024-12-01T16:37:46.188Z","updated_at":"2025-10-15T22:47:54.959Z","avatar_url":"https://github.com/czim.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Model Comparer\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status](https://travis-ci.org/czim/laravel-modelcomparer.svg?branch=master)](https://travis-ci.org/czim/laravel-modelcomparer)\n\n\nThis model comparer is a tool to make it easy to collect, log and report changes made to Eloquent models and their relations.\n\nIt's easy enough to compare model attributes before and after (or using `getDirty()`, during) updates for a single Eloquent model.\nUnfortunately, it is arduous to track updates while updating deeply nested relational model structures.\n\nWith this package, it's as simple as loading in the model before making changes, then loading it in again after.\nThe comparer instance tracks the changes and offers the means to create concise changelogs.\n\n\n## Version Compatibility\n\n| Laravel       | Package | PHP Version |\n|:--------------|:--------|:------------|\n| 5.3 and older | 0.9     |\n| 5.4 to 5.7    | 1.4     |\n| 5.8           | 1.5     |\n| 5.8, 6.0+     | 2.0     |\n| 9.0+          | 3.0     | 8.1+        |\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require czim/laravel-modelcomparer\n```\n\nIf you're not using auto-discovery (or are installing a version older than 3.0),\nadd the service provider in your `config/app.php` config.\n\n``` php\n    Czim\\ModelComparer\\ModelComparerServiceProvider::class,\n```\n\n\n## Usage\n\n1. Initialize a comparer instance\n2. Before making changes, set the before state on the comparer by passing in the model\n3. Make your changes to anything related to the model\n4. Run the comparison by passing in the model again\n\nThe result is an comparison information object that stores all the changes and offers means for easy logging.\n\n\n## To Do\n\n- Add singleton with facade for easy tracking of changes\n    - would use the model's class \u0026 key to keep track of before states and allow setting after states\n    - might even be done using an observer pattern\n    - note: not recommended for long running processes, unless cleanup methods are used to keep memory load small\n\n- Better change tracking for related models\n    - Track before state index by model class \u0026 key in the comparer\n        - And, singleton should delegate this to currently active comparers\n    - Track changes of a model when it is still via-via related before AND after (but for a different intermediary relation)\n    - Allow manually 'loading in' before state for a to-be related model\n\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n\n## Credits\n\n- [Coen Zimmerman][link-author]\n- [All Contributors][link-contributors]\n\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/czim/laravel-modelcomparer.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/czim/laravel-modelcomparer.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/czim/laravel-modelcomparer\n[link-downloads]: https://packagist.org/packages/czim/laravel-modelcomparer\n[link-author]: https://github.com/czim\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fczim%2Flaravel-modelcomparer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fczim%2Flaravel-modelcomparer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fczim%2Flaravel-modelcomparer/lists"}