Laravel-activitylog: Limiting detected model changes to defined attributes

Created on 21 Jul 2016  路  2Comments  路  Source: spatie/laravel-activitylog

I was hoping to prevent a log occurring on a model "updating" event if the change only happened to a particular attribute. For example, I have a datetime field in a user model that I don't want to log changes to, and therefore don't want an activitylog entry if the changes only happened to that field.

Defining the $logAttributes property determines what gets stored for a model, but I can't see if any comparison actually happens to see if anything has actually changed.

Is there currently a way to do this?

Most helpful comment

For diff the 2 values, a little shortcode..

collect($changes->get('attributes'))->diff($changes->get('old'))

returns only the changed properties and values

All 2 comments

No, you need to compare old and attributes yourself.

For diff the 2 values, a little shortcode..

collect($changes->get('attributes'))->diff($changes->get('old'))

returns only the changed properties and values

Was this page helpful?
0 / 5 - 0 ratings