diff --git a/src/MediaCollections/Models/Concerns/IsSorted.php b/src/MediaCollections/Models/Concerns/IsSorted.php index b80f500a0..4720eadef 100644 --- a/src/MediaCollections/Models/Concerns/IsSorted.php +++ b/src/MediaCollections/Models/Concerns/IsSorted.php @@ -15,7 +15,9 @@ public function setHighestOrderNumber(): void public function getHighestOrderNumber(): int { - return (int) static::max($this->determineOrderColumnName()); + return (int) static::where('model_type', $this->model_type) + ->where('model_id', $this->model_id) + ->max($this->determineOrderColumnName()); } public function scopeOrdered(Builder $query): Builder