2017 © Pedro Peláez
 

library laravel-modelcomparer

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

image

czim/laravel-modelcomparer

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

  • Tuesday, November 7, 2017
  • by czim
  • Repository
  • 1 Watchers
  • 0 Stars
  • 112 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 2 % Grown

The README.md

Laravel Model Comparer

Latest Version on Packagist ![Software License][ico-license] Build Status, (*1)

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

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., (*3)

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., (*4)

Version Compatibility

Laravel Package PHP Version
5.3 and older 0.9
5.4 to 5.7 1.4
5.8 1.5
5.8, 6.0+ 2.0
9.0+ 3.0 8.1+

Install

Via Composer, (*5)

``` bash $ composer require czim/laravel-modelcomparer, (*6)


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. ``` php Czim\ModelComparer\ModelComparerServiceProvider::class,

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., (*7)

To Do

  • Add singleton with facade for easy tracking of changes, (*8)

    • would use the model's class & 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, (*9)

    • Track before state index by model class & 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

Please see CONTRIBUTING for details., (*10)

Credits

License

The MIT License (MIT). Please see License File for more information., (*11)

The Versions

07/11 2017

dev-laravel-5.4

dev-laravel-5.4 https://github.com/czim/laravel-modelcomparer

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

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

log eloquent model

07/11 2017

1.4.1

1.4.1.0 https://github.com/czim/laravel-modelcomparer

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

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

log eloquent model

07/11 2017

dev-master

9999999-dev https://github.com/czim/laravel-modelcomparer

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

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

log eloquent model

03/09 2017

1.4.0

1.4.0.0 https://github.com/czim/laravel-modelcomparer

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

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

log eloquent model

03/09 2017

dev-laravel-5.5

dev-laravel-5.5 https://github.com/czim/laravel-modelcomparer

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

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

log eloquent model

03/09 2017

dev-laravel-5.3

dev-laravel-5.3 https://github.com/czim/laravel-modelcomparer

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

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

log eloquent model

13/02 2017

0.9.3

0.9.3.0 https://github.com/czim/laravel-modelcomparer

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

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

log eloquent model

30/01 2017

0.9.2

0.9.2.0 https://github.com/czim/laravel-modelcomparer

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

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

log eloquent model

29/01 2017

0.9.1

0.9.1.0 https://github.com/czim/laravel-modelcomparer

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

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

log eloquent model