@php $poll = $getRecord(); $options = $poll->options ?? []; $totalVotes = $poll->votes()->count(); $optionCounts = array_fill(0, count($options), 0); $allSelections = $poll->votes()->pluck('selected_options'); foreach ($allSelections as $selections) { foreach ($selections as $optionIndex) { if (isset($optionCounts[$optionIndex])) { $optionCounts[$optionIndex]++; } } } // Find the leading option $maxVotes = count($optionCounts) > 0 ? max($optionCounts) : 0; @endphp
{{ $totalVotes }} total {{ $totalVotes === 1 ? 'vote' : 'votes' }}
@if($totalVotes === 0)

No votes have been cast yet.

@else
@foreach($options as $index => $option) @php $count = $optionCounts[$index] ?? 0; $percentage = $totalVotes > 0 ? round(($count / $totalVotes) * 100, 1) : 0; $isLeading = $count === $maxVotes && $count > 0; @endphp
{{ $option['text'] ?? $option }} @if($isLeading) ● Leading @endif {{ $count }} ({{ $percentage }}%)
@endforeach
@endif