Skip to content

Commit

Permalink
Merge pull request #26 from Laravel-Backpack/ensure-we-have-an-array-…
Browse files Browse the repository at this point in the history
…of-uploads

ensure we have an array in array_filter function
  • Loading branch information
pxpm authored Dec 5, 2023
2 parents 01984f3 + b039483 commit 88223a4
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Uploaders/MediaAjaxUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ public function uploadFiles(Model $entry, $value = null)
$temporaryDisk = CRUD::get('dropzone.temporary_disk');
$temporaryFolder = CRUD::get('dropzone.temporary_folder');

$uploads = $value ?? CRUD::getRequest()->input($this->getName());
$uploads = $value ?? CRUD::getRequest()->input($this->getName()) ?? [];

if (! is_array($uploads) && is_string($uploads)) {
$uploads = json_decode($uploads, true) ?? [];
}
$uploads = is_array($uploads) ? $uploads : (json_decode($uploads, true) ?? []);

$uploadedFiles = array_filter($uploads, function ($value) use ($temporaryFolder, $temporaryDisk) {
return strpos($value, $temporaryFolder) !== false && Storage::disk($temporaryDisk)->exists($value);
Expand Down

0 comments on commit 88223a4

Please sign in to comment.