@if(isset($bracket['matches']) && count($bracket['matches']) > 0)
@php
$rounds = $bracket['rounds'];
$matchesByRound = collect($bracket['matches'])->groupBy('round');
@endphp
@for($round = 1; $round <= $rounds; $round++)
@if($round == 1)
Round 1
@elseif($round == $rounds)
Final
@elseif($round == $rounds - 1)
Semi-Final
@else
Round {{ $round }}
@endif
@if(isset($matchesByRound[$round]))
@foreach($matchesByRound[$round] as $match)
{{ $match['player_a']['username'] ?? 'TBD' }}
@if(($match['winner'] ?? null) === ($match['player_a']['id'] ?? null))
✓
@endif
VS
{{ $match['player_b']['username'] ?? 'TBD' }}
@if(($match['winner'] ?? null) === ($match['player_b']['id'] ?? null))
✓
@endif
@if($match['status'] === 'completed')
✓ Completed
@elseif($match['status'] === 'pending')
⏳ In Progress
@else
⏸ Waiting
@endif
@endforeach
@endif
{{-- Connection lines between rounds --}}
@if($round < $rounds)
@endif
@endfor
{{-- Tournament Winner --}}
@if($rounds > 0 && isset($matchesByRound[$rounds]))
@php
$finalMatch = $matchesByRound[$rounds]->first();
$winner = null;
if (($finalMatch['winner'] ?? null) === ($finalMatch['player_a']['id'] ?? null)) {
$winner = $finalMatch['player_a'];
} elseif (($finalMatch['winner'] ?? null) === ($finalMatch['player_b']['id'] ?? null)) {
$winner = $finalMatch['player_b'];
}
@endphp
@if($winner)
🏆
Tournament Champion
{{ $winner['username'] }}
Bracket will be generated when tournament starts