diff --git a/src/Translatable/Translatable.php b/src/Translatable/Translatable.php index a481b0b..c7e3578 100644 --- a/src/Translatable/Translatable.php +++ b/src/Translatable/Translatable.php @@ -252,31 +252,23 @@ public function setAttribute($key, $value) */ public function save(array $options = []) { - if ($this->exists) { - if ($this->isDirty()) { - // If $this->exists and dirty, parent::save() has to return true. If not, - // an error has occurred. Therefore we shouldn't save the translations. - if (parent::save($options)) { - return $this->saveTranslations(); - } - + if ($this->exists && ! $this->isDirty()) { + // If $this->exists and not dirty, parent::save() skips saving and returns + // false. So we have to save the translations + if ($this->fireModelEvent('saving') === false) { return false; - } else { - // If $this->exists and not dirty, parent::save() skips saving and returns - // false. So we have to save the translations - if ($this->fireModelEvent('saving') === false) { - return false; - } - - if ($saved = $this->saveTranslations()) { - $this->fireModelEvent('saved', false); - $this->fireModelEvent('updated', false); - } + } - return $saved; + if ($saved = $this->saveTranslations()) { + $this->fireModelEvent('saved', false); + $this->fireModelEvent('updated', false); } - } elseif (parent::save($options)) { - // We save the translations only if the instance is saved in the database. + + return $saved; + } + + // We save the translations only if the instance is saved in the database. + if (parent::save($options)) { return $this->saveTranslations(); }