From 621d1b623a855e0142ce8fcdb2cbf3a1dd833b9a Mon Sep 17 00:00:00 2001 From: Zatakata Date: Wed, 3 Apr 2024 17:49:56 +0300 Subject: [PATCH] fix: orderMedia method --- src/Fields/MediaLibrary.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Fields/MediaLibrary.php b/src/Fields/MediaLibrary.php index b900a32..c74da58 100644 --- a/src/Fields/MediaLibrary.php +++ b/src/Fields/MediaLibrary.php @@ -66,7 +66,7 @@ protected function resolveAfterApply(mixed $data): mixed $this->removeOldMedia($data, $recentlyCreated, $oldValues); - $this->orderMedia($recentlyCreated, $oldValues); + $this->orderMedia($recentlyCreated); return null; } @@ -99,10 +99,8 @@ private function addMedia(HasMedia $item, UploadedFile $file): Media ->toMediaCollection($this->column()); } - private function orderMedia(Collection $recentlyCreated, Collection $oldValues): void + private function orderMedia(Collection $recentlyCreated): void { - $ids = $oldValues->merge($recentlyCreated)->pluck('id')->toArray(); - - Media::setNewOrder($ids); + Media::setNewOrder($recentlyCreated->pluck('id')->toArray()); } }