Skip to content

Newly created models don't serialize all attributes #101

@KeithTurkowski

Description

@KeithTurkowski

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions