DirectoryTree / LdapRecord

A fully-featured LDAP framework.
https://ldaprecord.com
MIT License
514 stars 44 forks source link

Add "changes" API to models #647

Closed stevebauman closed 1 year ago

stevebauman commented 1 year ago

This PR implements the ability to retrieve changes on a model after an update has been performed.

This is really handy to be able to retrieve all of the changed attributes of a model, after an update:

use LdapRecord\Models\Entry;

$model = Entry::find('cn=jdoe,dc=local,dc=com');

$model->mail = 'foo@email.com';

$model->save();

$model->wasChanged(); // true

$model->wasChanged('mail'); // true

$model->wasChanged('invalid'); // false

$model->wasChanged(['mail', 'invalid']); // true

$model->getChanges(); // ['mail' => ['foo@email.com']]