From 28ab73182cff6d5b7996856c574d2cb073787a33 Mon Sep 17 00:00:00 2001 From: Karan Datwani Date: Thu, 20 Jun 2024 20:12:19 +0530 Subject: [PATCH 1/2] pass entry param --- src/Uploaders/MediaUploader.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Uploaders/MediaUploader.php b/src/Uploaders/MediaUploader.php index d6b9971..ab31c04 100644 --- a/src/Uploaders/MediaUploader.php +++ b/src/Uploaders/MediaUploader.php @@ -90,11 +90,11 @@ public function retrieveUploadedFiles(Model $entry): Model if (! is_array($values)) { $values = json_decode($values, true); } - + $repeatableUploaders = array_merge(app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()), [$this]); foreach ($repeatableUploaders as $uploader) { $uploadValues = $uploader->getPreviousRepeatableValues($entry); - + $values = $this->mergeValuesRecursive($values, $uploadValues); } @@ -161,7 +161,7 @@ protected function addMediaFile($entry, $file, $order = null) $constrainedMedia->setMediaUploader($this); if ($this->savingEventCallback && is_callable($this->savingEventCallback)) { - $constrainedMedia = call_user_func_array($this->savingEventCallback, [$constrainedMedia, $this]); + $constrainedMedia = call_user_func_array($this->savingEventCallback, [$constrainedMedia, $this,$entry]); } if (! $constrainedMedia) { @@ -209,7 +209,7 @@ protected function getPreviousRepeatableMedia(Model $entry) }); $previousMedia->each(function($item) use (&$orderedMedia) { $orderedMedia[] = $item[$this->getName()]; - }); + }); return $orderedMedia; } @@ -236,7 +236,7 @@ private function initFileAdder($entry, $file) if (get_class($file) === File::class) { return $entry->addMedia($file->getPathName()); } - + } private function getConversionToDisplay($item) From d380fa00b4ed3fbc37d795a8e3bb3c530e2563c5 Mon Sep 17 00:00:00 2001 From: Karan Datwani Date: Thu, 20 Jun 2024 20:13:47 +0530 Subject: [PATCH 2/2] misc --- src/Uploaders/MediaUploader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Uploaders/MediaUploader.php b/src/Uploaders/MediaUploader.php index ab31c04..7cce107 100644 --- a/src/Uploaders/MediaUploader.php +++ b/src/Uploaders/MediaUploader.php @@ -161,7 +161,7 @@ protected function addMediaFile($entry, $file, $order = null) $constrainedMedia->setMediaUploader($this); if ($this->savingEventCallback && is_callable($this->savingEventCallback)) { - $constrainedMedia = call_user_func_array($this->savingEventCallback, [$constrainedMedia, $this,$entry]); + $constrainedMedia = call_user_func_array($this->savingEventCallback, [$constrainedMedia, $this, $entry]); } if (! $constrainedMedia) {