Skip to content

Commit

Permalink
Merge pull request #279 from lee-to/json-file-support
Browse files Browse the repository at this point in the history
Json file support
  • Loading branch information
lee-to authored May 18, 2023
2 parents 81c467d + 4c5ac61 commit bda6e8d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Fields/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,20 @@ public function save(Model $item): Model
return $item;
}

$item->{$this->field()} = $this->mapKeyValue(collect($this->requestValue()));
$requestValues = $this->requestValue();

foreach ($requestValues as $index => $values) {
foreach ($this->getFields() as $field) {
if ($field instanceof Fileable) {
$requestValues[$index] = $field->hasManyOrOneSave(
"hidden_{$this->field()}.$index.{$field->field()}",
$values
);
}
}
}

$item->{$this->field()} = $this->mapKeyValue(collect($requestValues));

return $item;
}
Expand Down

0 comments on commit bda6e8d

Please sign in to comment.