Skip to content

Commit

Permalink
Merge pull request #9620 from cl8n/tracks-order
Browse files Browse the repository at this point in the history
Use consistent order for FA tracks
  • Loading branch information
notbakaneko authored Oct 6, 2023
2 parents f51ea30 + 307add4 commit a5beb1b
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions app/Http/Controllers/ArtistsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,31 @@ public function show($id)
$albums = $artist->albums()
->where('visible', true)
->orderBy('id', 'desc')
->with(['tracks' => function ($query) {
$query->orderBy('display_order', 'ASC');
}])
->with('tracks.artist')
->with(['tracks' => fn ($q) => $q
->orderBy('display_order', 'asc')
->orderBy('exclusive', 'desc')
->orderBy('id', 'asc'),
])
->get();

$tracks = $artist
->tracks()
->whereNull('album_id')
->with('artist')
->orderBy('display_order', 'asc')
->orderBy('exclusive', 'desc')
->orderBy('id', 'desc')
->get();

foreach ($albums as $album) {
foreach ($album->tracks as $track) {
$track->setRelation('album', $album);
$track->setRelation('artist', $artist);
}
}
foreach ($tracks as $track) {
$track->setRelation('artist', $artist);
}

$images = [
'header_url' => $artist->header_url,
'cover_url' => $artist->cover_url,
Expand Down

0 comments on commit a5beb1b

Please sign in to comment.