Skip to content

Commit

Permalink
Handle an upcoming song not being played yet
Browse files Browse the repository at this point in the history
  • Loading branch information
mintopia committed Jan 1, 2025
1 parent f10d5f7 commit 526c0e6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/Http/Controllers/UpcomingSongController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use App\Models\Party;
use App\Models\UpcomingSong;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;

class UpcomingSongController extends Controller
{
Expand Down Expand Up @@ -98,7 +100,11 @@ public function show(PaginationRequest $request, Party $party, UpcomingSong $son
}
$votes = $song->votes()->orderBy('created_at', 'ASC')->with(['user', 'user.partyMembers'])->paginate($perPage)->appends($params);
$other = $party->upcoming()->whereSongId($song->song_id)->where('id', '<>', $song->id)->withCount('votes')->orderBy('created_at', 'DESC')->get();
$ratings = $song->played->ratings()->orderBy('created_at', 'ASC')->with(['user', 'user.partyMembers'])->paginate($perPage)->appends($params);
if ($song->played) {
$ratings = $song->played->ratings()->orderBy('created_at', 'ASC')->with(['user', 'user.partyMembers'])->paginate($perPage)->appends($params);
} else {
$ratings = new LengthAwarePaginator([], 0, $perPage);
}
return view('upcomingsongs.show', [
'party' => $party,
'canManage' => true,
Expand Down

0 comments on commit 526c0e6

Please sign in to comment.