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
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
{
protectedfunctioncopyAttributesToVersion(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
{
protectedfunctioncopyAttributesToVersionable($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
}
}
The text was updated successfully, but these errors were encountered:
hagabaka
pushed a commit
to hagabaka/versionable
that referenced
this issue
Nov 16, 2018
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.
The text was updated successfully, but these errors were encountered: