protected versionablePostSave ( ) : void | ||
return | void |
protected function versionablePostSave()
{
/**
* We'll save new versions on updating and first creation
*/
if ($this->versioningEnabled === true && $this->updating && $this->isValidForVersioning() || $this->versioningEnabled === true && !$this->updating && count($this->versionableDirtyData)) {
// Save a new version
$version = new Version();
$version->versionable_id = $this->getKey();
$version->versionable_type = get_class($this);
$version->user_id = $this->getAuthUserId();
$version->model_data = serialize($this->getAttributes());
if (!empty($this->reason)) {
$version->reason = $this->reason;
}
$version->save();
}
}