From 0fdd2662497f27d1dc68619a556e55e317c29ba0 Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Tue, 3 Oct 2023 21:28:38 +0100 Subject: [PATCH] Fixes issue with attaching media Signed-off-by: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> --- app/admin/formwidgets/MediaFinder.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/admin/formwidgets/MediaFinder.php b/app/admin/formwidgets/MediaFinder.php index 829fd42fcb..1d066568a6 100644 --- a/app/admin/formwidgets/MediaFinder.php +++ b/app/admin/formwidgets/MediaFinder.php @@ -131,8 +131,7 @@ public function getMediaPath($media) try { return MediaLibrary::instance()->getMediaRelativePath(trim($media, '/')); - } - catch (SystemException $ex) { + } catch (SystemException $ex) { return $media; } } @@ -238,13 +237,13 @@ public function onAddAttachment() )); } - $items = $this->validate(request()->input(), [ + $data = $this->validate(request()->input(), [ 'items' => ['required', 'array'], 'items.*.name' => ['required', 'string'], 'items.*.path' => ['required', 'string'], ]); - if (!is_array($items)) + if (!is_array($items = array_get($data, 'items'))) throw new ApplicationException(lang('main::lang.media_manager.alert_select_item_to_attach')); $model = $this->model;