Skip to content

Commit 0dd5c8d

Browse files
committed
fix return value of repeatable uploaders
1 parent 4f334df commit 0dd5c8d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/app/Library/Uploaders/Support/Traits/HandleRepeatableUploads.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Database\Eloquent\Model;
88
use Illuminate\Support\Collection;
99
use Illuminate\Support\Facades\Storage;
10+
use Illuminate\Support\Str;
1011

1112
trait HandleRepeatableUploads
1213
{
@@ -90,7 +91,18 @@ private function retrieveRepeatableFiles(Model $entry): Model
9091
if ($this->isRelationship) {
9192
return $this->retrieveFiles($entry);
9293
}
93-
94+
$values = $entry->{$this->getRepeatableContainerName()};
95+
$values = is_string($values) ? json_decode($values, true) : $values;
96+
$repeatableUploaders = app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName());
97+
$values = array_map(function($item) use ($repeatableUploaders) {
98+
foreach ($repeatableUploaders as $upload) {
99+
$item[$upload->getName()] = isset($item[$upload->getName()]) ? Str::after($item[$upload->getName()], $upload->getPath()) : null;
100+
}
101+
return $item;
102+
103+
}, $values);
104+
105+
$entry->{$this->getRepeatableContainerName()} = $values;
94106
return $entry;
95107
}
96108

0 commit comments

Comments
 (0)