{{-- Rating Stars Component: Display star rating with review count --}} @props(['rating' => 4.8, 'reviewCount' => 2100, 'size' => 'md']) @php $fullStars = floor($rating); $hasHalfStar = ($rating - $fullStars) >= 0.5; $emptyStars = 5 - $fullStars - ($hasHalfStar ? 1 : 0); $sizeClasses = [ 'sm' => 'w-4 h-4', 'md' => 'w-5 h-5', 'lg' => 'w-6 h-6' ]; $iconSize = $sizeClasses[$size] ?? $sizeClasses['md']; @endphp
{{-- Star Rating: Flex container with stars --}}
{{-- Full Stars: Yellow/gold color for filled stars --}} @for($i = 0; $i < $fullStars; $i++) @endfor {{-- Half Star: If rating has 0.5 --}} @if($hasHalfStar)
{{-- Background empty star --}} {{-- Foreground half-filled star --}}
@endif {{-- Empty Stars: Gray color for unfilled stars --}} @for($i = 0; $i < $emptyStars; $i++) @endfor
{{-- Rating Text: Display rating number and review count --}} {{ number_format($rating, 1) }}/5 @if($reviewCount > 0) ({{ number_format($reviewCount) }}+ reviews) @endif