Log all properties but only when a change in one is detected #745
Unanswered
ifranlaloe
asked this question in
Q&A
Replies: 1 comment 3 replies
-
I've used your mentioned 4 configuration properties and added a testcase in #747 - below is the JSON dump of the logged changes after updating only the {
"attributes":{
"id":3,
"name":"my changed name",
"text":"my text",
"user_id":null,
"json":null,
"price":null
},
"old":{
"id":3,
"name":"my name",
"text":"my text",
"user_id":null,
"json":null,
"price":null
}
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I ran into a use case where these properties didn't cut it:
$onlyDirty=true
almost got me there in combination with$submitEmptyLogs=false
.They made it possible to log only with "real" changes, but I also want to see all the fields of the changed record.
The use case
Log all the properties when one of the properties in "old" and "new" are different. But ignore updated_at.
My solution
My solution for now is not pretty, but it makes updating the DetectsChanges.php simple
I decided to use the $onlyDirty functionaltity for finding changes but with maintaining all the properties
static::logAllWhenChangesDetected
with functionshouldLogAllWhenChangesDetected()
.$this->shouldLogOnlyDirty() && isset($properties['old'])
As you can see it's a direct copy of the $onlyDirty functionality. Of course when it would be implemented it could be a lot cleaner. Copying causes a lot of overhead.
I hope that you will consider this feature. Feel free to contact me if you have any question.
Or let me know if I missed something in the documentation that does make this possible with another property.
Beta Was this translation helpful? Give feedback.
All reactions