public function formCreateModelObject() { $model = new Translation(); $latest = Translation::currentTranslation($this->locale->id, $this->label->id)->first(); if ($latest && $latest->translation) { $model->translation = $latest->translation; } $model->locale = $this->locale; $model->locale_id = $this->locale->id; $model->label = $this->label; $model->label_id = $this->label->id; $model->author_id = BackendAuth::getUser()->id; return $model; }
/** * Before saving this model, check if other translation does not have to be pull out or put into archive */ public function beforeSave() { if (!$this->deleted_at) { Translation::currentTranslation($this->locale_id, $this->label_id)->delete(); } }