Skip to content

Commit

Permalink
Merge pull request #291 from lee-to/1.5.x
Browse files Browse the repository at this point in the history
refactor(fields): File field
  • Loading branch information
lee-to authored May 22, 2023
2 parents e8571a8 + 31748dc commit 160ec7e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Traits/Fields/FileTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ public function store(UploadedFile $file): string
public function hasManyOrOneSave($hiddenKey, array $values = [], Model $item = null): array
{
if ($this->isMultiple()) {
$saveValues = collect(request($hiddenKey, []))
$saveValues = request()
->collect($hiddenKey)
->reject(fn ($v) => is_numeric($v));

if (isset($values[$this->field()])) {
Expand Down Expand Up @@ -168,7 +169,7 @@ public function hasManyOrOneSave($hiddenKey, array $values = [], Model $item = n
public function save(Model $item): Model
{
$requestValue = $this->requestValue();
$oldValues = collect(request("hidden_{$this->field()}", []));
$oldValues = request()->collect("hidden_{$this->field()}");

if($this->isDeleteFiles()) {
$this->checkAndDelete($item->{$this->field()}, $oldValues->toArray());
Expand Down

0 comments on commit 160ec7e

Please sign in to comment.