{{ $contest->title ?? 'Contest Details' }}

@php $isGrid = $entries->count() > 3; $winners = \App\Models\ContestWinner::with('prize') ->where('contest_id', $contest->id) ->get(); @endphp
@forelse($entries as $entry) @php $entryId = (string) $entry->id; $winner = $winners->first(fn($w) => (string) $w->contest_entry_id === $entryId); $isWinner = $winner !== null; $groupedAnswers = $entry->quizAnswers?->groupBy('quiz_question_id') ?? collect(); $quizCount = $groupedAnswers->count(); $isCompact = $quizCount > 2; @endphp

Entry ID: {{ $entry->id }}

@if($isWinner) 🏆 Winner @else Not Winner @endif

Submitted At: {{ $entry->created_at?->format('d M Y, h:i A') ?? '-' }}

@if($isWinner && optional($winner)->prize)
@if(optional($winner)->rank_position) #{{ $winner->rank_position }} @endif

🎁 Prize: {{ optional($winner->prize)->title ?? '-' }}

@php $desc = trim(strip_tags(optional($winner->prize)->description ?? '')); @endphp

{{ $desc ?: '-' }}

@endif @if($groupedAnswers->count())

Quiz Answers:

@foreach($groupedAnswers as $answers) @php $question = $answers->first()->question; $correctOptions = $question?->options?->where('is_correct', true); $selectedTexts = $answers->pluck('option.option_text')->filter()->map(fn($v) => strtolower(trim($v)))->sort()->values(); $correctTexts = $correctOptions?->pluck('option_text')->filter()->map(fn($v) => strtolower(trim($v)))->sort()->values(); $isCorrect = $correctTexts->diff($selectedTexts)->isEmpty() && $selectedTexts->diff($correctTexts)->isEmpty(); @endphp

{{ $question->question_text ?? '-' }}

Ans: {{ $answers->pluck('option.option_text')->filter()->join(', ') ?: '-' }}

@if($isCompact)

@if($isCorrect) @else @endif

@else

Correct: {{ $correctOptions?->pluck('option_text')->join(', ') ?: '-' }}

@if($isCorrect) ✔ Correct @else ✘ Wrong @endif

@endif
@endforeach
@endif @php $predictions = $entry->matchPredictions ?? collect(); $resultLabelMap = [ 'home_win' => 'Home Win', 'away_win' => 'Away Win', 'draw' => 'Draw', '1' => 'Home Win', '2' => 'Away Win', 'X' => 'Draw', ]; function getResultLabel(array $map, $raw): string { if (!is_string($raw) && !is_int($raw)) return '-'; $key = (string) $raw; return $map[$key] ?? $key; } @endphp @if($predictions->isNotEmpty())

Match Predictions:

@foreach($predictions as $p) @php $rawPrediction = is_string($p->prediction) ? $p->prediction : null; $predictionLabel = $rawPrediction ? ($resultLabelMap[$rawPrediction] ?? $rawPrediction) : '-'; $rawResult = $p->match?->result ?? null; if (is_array($rawResult)) { $rawResult = $rawResult['result_type'] ?? null; } elseif (is_string($rawResult) && str_starts_with(trim($rawResult), '{')) { $decoded = json_decode($rawResult, true); $rawResult = is_array($decoded) ? ($decoded['result_type'] ?? null) : null; } elseif (!is_string($rawResult)) { $rawResult = null; } $resultLabel = $rawResult ? ($resultLabelMap[$rawResult] ?? $rawResult) : null; $isCorrectPrediction = $rawPrediction && $rawResult && ( $rawPrediction === $rawResult || ($resultLabelMap[$rawPrediction] ?? null) === ($resultLabelMap[$rawResult] ?? null) ); @endphp

{{ $p->match?->homeTeam?->team_name ?? 'Team A' }} vs {{ $p->match?->awayTeam?->team_name ?? 'Team B' }}

Sport: Football

@if($resultLabel)

Final: {{ $resultLabel }}

@endif

Predicted: {{ $predictionLabel }}

@endforeach
@endif
@empty

No entries found.

@endforelse