diff --git a/src/Traits/HasMedia.php b/src/Traits/HasMedia.php index 0f18227..fe6c26a 100644 --- a/src/Traits/HasMedia.php +++ b/src/Traits/HasMedia.php @@ -16,11 +16,19 @@ * @template TMedia of Media * * @property ?string $uuid - * @property EloquentCollection $media + * @property EloquentCollection $media ordered by order, id + * @property EloquentCollection $unorderedMedia */ trait HasMedia { public function media(): MorphMany + { + return $this->morphMany(config('media.model'), 'model') + ->orderBy('order') + ->orderBy('id'); + } + + public function unorderedMedia(): MorphMany { return $this->morphMany(config('media.model'), 'model'); }