@props(['rating' => 0, 'count' => null, 'size' => 'small']) @php $fullStars = floor($rating); $hasHalfStar = $rating - $fullStars >= 0.5; $emptyStars = 5 - $fullStars - ($hasHalfStar ? 1 : 0); $starSize = match($size) { 'large' => 'w-5 h-5', 'medium' => 'w-4 h-4', default => 'w-3.5 h-3.5' }; $textSize = match($size) { 'large' => 'text-sm', 'medium' => 'text-xs', default => 'text-xs' }; @endphp
{{-- Full Stars --}} @for ($i = 0; $i < $fullStars; $i++) @endfor {{-- Half Star --}} @if ($hasHalfStar)
@endif {{-- Empty Stars --}} @for ($i = 0; $i < $emptyStars; $i++) @endfor
{{-- Rating Number and Count --}} @if ($count !== null) {{ number_format($rating, 1) }} ({{ number_format($count) }}) @elseif ($rating > 0) {{ number_format($rating, 1) }} @endif