Similar to #84, but basically I found that using setRawAttributes() is just not desired at all. When a model that has been reverted needs to be serialized (e.g. in an API response) it fails because the raw attributes array may contain data in a format that Eloquent doesn't expect.
You need some mechanism to convert the cast data back into its raw type if you're going to use setRawAttributes().
So I found it's better to simply attempt to set the values on the model directly e.g.:
foreach ($this->contents as $key => $value) {
$this->versionable->$key = $value;
}
I noticed you were using forceFill at one point, which feels like it's the right approach, but I'm not clear why this needed to change.
Similar to #84, but basically I found that using
setRawAttributes()is just not desired at all. When a model that has been reverted needs to be serialized (e.g. in an API response) it fails because the raw attributes array may contain data in a format that Eloquent doesn't expect.You need some mechanism to convert the cast data back into its raw type if you're going to use
setRawAttributes().So I found it's better to simply attempt to set the values on the model directly e.g.:
I noticed you were using
forceFillat one point, which feels like it's the right approach, but I'm not clear why this needed to change.