Skip to content

Commit

Permalink
Merge pull request #11 from z-takaev/patch-2
Browse files Browse the repository at this point in the history
fix: orderMedia method
By @z-takaev
  • Loading branch information
alexvenga authored Apr 3, 2024
2 parents 117eeb4 + 621d1b6 commit 5854765
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Fields/MediaLibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected function resolveAfterApply(mixed $data): mixed

$this->removeOldMedia($data, $recentlyCreated, $oldValues);

$this->orderMedia($recentlyCreated, $oldValues);
$this->orderMedia($recentlyCreated);

return null;
}
Expand Down Expand Up @@ -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());
}
}

0 comments on commit 5854765

Please sign in to comment.