Skip to content

Commit

Permalink
INIT
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvenga committed Apr 24, 2023
1 parent 727d2e8 commit 9e13a9d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Fields/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']])
Expand All @@ -162,7 +163,8 @@ public function save(Model $item): Model
);
}

$item->{$this->field()} = $array;
$item->setTranslations($this->field(), $array);

}

return $item;
Expand Down

0 comments on commit 9e13a9d

Please sign in to comment.