Currently the serialization is done in VersionableTrait::versionablePostSave() with
$version->model_data = serialize($this->getAttributes());
and deserialization is done in Version::getModel() with
$model->fill(unserialize($modelData));
It would be nice if the method of serialization can be customized by overriding methods, for example to use JSONB column, or even a versions table with all the columns of the versioned model.
trait VersionableTrait
{
protected function copyAttributesToVersion(Version $version)
{
$version->model_data = serialize($this->getAttributes()); // default implementation
// or
$version->model_data = $this->getAttributesData(); // with a JSONB model_data column
// or
$version->fill($this->getAttributes()); // versions table with columns for all versioned attributes
}
}
class Version
{
protected function copyAttributesToVersionable($model)
{
$model->fill(unserialize($modelData)); // default implementation
$model->fill($modelData); // with a JSONB model_data column
$model->fill(array_only($this->getAttributes(), $versionedAttributes)); // versions table with columns for all versioned attributes
}
}
Currently the serialization is done in
VersionableTrait::versionablePostSave()withand deserialization is done in
Version::getModel()withIt would be nice if the method of serialization can be customized by overriding methods, for example to use JSONB column, or even a versions table with all the columns of the versioned model.