@php $averageRating = $reviews->avg('rating'); $fullStars = floor($averageRating); // Number of full stars $halfStar = $averageRating - $fullStars >= 0.5 ? 1 : 0; // Check if there's a half star $emptyStars = 5 - $fullStars - $halfStar; // Remaining stars are empty // Count the number of reviews for each rating $starCounts = [ 5 => $reviews->where('rating', 5)->count(), 4 => $reviews->where('rating', 4)->count(), 3 => $reviews->where('rating', 3)->count(), 2 => $reviews->where('rating', 2)->count(), 1 => $reviews->where('rating', 1)->count(), ]; // Calculate the total number of reviews $totalReviews = $reviews->count(); @endphp
{!! $review->review !!}
{{ $review->created_at->format('d F Y') }}
@for ($i = 0; $i < $fullStars; $i++)-
@endfor
@for ($i = 0; $i < $emptyStars; $i++)
-
@endfor