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;