You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe that you should check wasRecentlyCreated on models and reload them if it is true before calling attributesToArray.
Currently, because you are using attributesToArray, newly created models will only return attributes that have been modified / updated. This means the attributes list may not be complete, and the next time the model is loaded and modified, then all attributes will be returned with attributesToArray... This will result in the second "version" of the model including the attributes, even if they haven't been modified, and it will appear as if they were changed when doing a diff. I also suspect that it would cause issues when attempting to roll back to the initial version.
My current workaround is to using a create method on the model to do: $model = self::find(self::create()->id) to ensure that the initial version contains the full list of serialized attributes.
The text was updated successfully, but these errors were encountered:
I believe that you should check wasRecentlyCreated on models and reload them if it is true before calling
attributesToArray
.Currently, because you are using
attributesToArray
, newly created models will only return attributes that have been modified / updated. This means the attributes list may not be complete, and the next time the model is loaded and modified, then all attributes will be returned withattributesToArray
... This will result in the second "version" of the model including the attributes, even if they haven't been modified, and it will appear as if they were changed when doing a diff. I also suspect that it would cause issues when attempting to roll back to the initial version.My current workaround is to using a create method on the model to do:
$model = self::find(self::create()->id)
to ensure that the initial version contains the full list of serialized attributes.The text was updated successfully, but these errors were encountered: