From e46cacc27643cbfc637603dfa8ad13a552c72ce7 Mon Sep 17 00:00:00 2001 From: SWEETIS Date: Mon, 17 Jul 2023 16:30:42 +0300 Subject: [PATCH 1/3] fix(methods): Fix method save The method could not delete old values, added instead of setTranslations, replaceTranslations, which fixes the problem --- src/Fields/Translatable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fields/Translatable.php b/src/Fields/Translatable.php index 2745cf3..7ddf71f 100644 --- a/src/Fields/Translatable.php +++ b/src/Fields/Translatable.php @@ -172,7 +172,7 @@ public function save(Model $item): Model ); } - $item->setTranslations($this->field(), $array); + $item->replaceTranslations($this->field(), $array); } From c437f87f5a4150e0da9305056f4ee5efe8184d70 Mon Sep 17 00:00:00 2001 From: SWEETIS Date: Mon, 17 Jul 2023 16:59:09 +0300 Subject: [PATCH 2/3] fix(methods): Fix method save The method could not delete old values, added instead of setTranslations, replaceTranslations, which fixes the problem --- src/Fields/Translatable.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Fields/Translatable.php b/src/Fields/Translatable.php index 7ddf71f..bbf4dd5 100644 --- a/src/Fields/Translatable.php +++ b/src/Fields/Translatable.php @@ -172,7 +172,12 @@ public function save(Model $item): Model ); } - $item->replaceTranslations($this->field(), $array); + if ($this->isRemovable()) { + $item->replaceTranslations($this->field(), $array); + return $item; + } + + $item->setTranslations($this->field(), $array); } From 8bcc8f06f440578492280cd5ef8ebabd1914b9c5 Mon Sep 17 00:00:00 2001 From: SWEETIS Date: Mon, 17 Jul 2023 17:08:16 +0300 Subject: [PATCH 3/3] style(methods): save method style --- src/Fields/Translatable.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Fields/Translatable.php b/src/Fields/Translatable.php index bbf4dd5..fa9a450 100644 --- a/src/Fields/Translatable.php +++ b/src/Fields/Translatable.php @@ -178,6 +178,7 @@ public function save(Model $item): Model } $item->setTranslations($this->field(), $array); + return $item; }