Skip to content

Commit

Permalink
ordered by default
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGab committed Jan 10, 2024
1 parent a4eba97 commit 54e56db
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Traits/HasMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@
* @template TMedia of Media
*
* @property ?string $uuid
* @property EloquentCollection<int, TMedia> $media
* @property EloquentCollection<int, TMedia> $media ordered by order, id
* @property EloquentCollection<int, TMedia> $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');
}
Expand Down

0 comments on commit 54e56db

Please sign in to comment.