Skip to content

Conversation

danhunsaker
Copy link

When adding a versioned attribute that also has a accessor or cast of some kind, the current code retrieves the accessor/casted version and attempts to store that, instead of the mutated DB-friendly version we would expect. This commit fixes that, by retrieving the value from the raw attributes array, instead of through the virtual property, and thereby skips any accessors/casts.

This issue came up while using this package along with Spatie's translatable models package, and MySQL throwing a fit about not wanting to save the non-JSON'd English translation of a value in a JSON field. This change fixes that issue, and probably many others besides.

When adding a versioned attribute that also has a accessor or cast of some kind, the current code retrieves the _accessor_/_casted_ version and attempts to store that, instead of the _mutated_ DB-friendly version we would expect. This commit fixes that, by retrieving the value from the raw attributes array, instead of through the virtual property, and thereby skips any accessors/casts.
@danhunsaker danhunsaker changed the title Avoid saving mutations to DB Avoid saving casts to DB Dec 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant