diff --git a/src/Fields/Translatable.php b/src/Fields/Translatable.php index 7fba24a..1e29163 100644 --- a/src/Fields/Translatable.php +++ b/src/Fields/Translatable.php @@ -152,6 +152,21 @@ public function hasFields(): bool return true; } + protected function resolveOnApply(): ?Closure + { + return function ($item) { + $translations = $this->requestValue() !== false + ? collect($this->requestValue())->mapWithKeys(function ($item) { + return [$item['key'] => $item['value']]; + })->toArray() + : $item->getTranslations($this->column()); + + $item->replaceTranslations($this->column(), $translations); + + return $item; + }; + } + protected function resolvePreview(): View|string { return $this?->data?->{$this->column()} ?? '';