From 9e13a9db461fd373da66e3bcb71bc01cadbe8382 Mon Sep 17 00:00:00 2001 From: alexvenga Date: Mon, 24 Apr 2023 22:15:05 +0300 Subject: [PATCH] INIT --- src/Fields/Translatable.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Fields/Translatable.php b/src/Fields/Translatable.php index 6f6b6c8..5911ead 100644 --- a/src/Fields/Translatable.php +++ b/src/Fields/Translatable.php @@ -145,6 +145,7 @@ public function formViewValue(Model $item): mixed public function save(Model $item): Model { if ($this->isCanSave() && $this->requestValue() !== false) { + $array = collect($this->requestValue()) ->filter(fn($data) => !empty($data['key']) && !empty($data['value'])) ->mapWithKeys(fn($data) => [$data['key'] => $data['value']]) @@ -162,7 +163,8 @@ public function save(Model $item): Model ); } - $item->{$this->field()} = $array; + $item->setTranslations($this->field(), $array); + } return $item;