@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

{{ number_format($averageRating, 1) }}

    @for ($i = 0; $i < $fullStars; $i++)
  • Full Star
  • @endfor @if ($halfStar)
  • Half Star
  • @endif @for ($i = 0; $i < $emptyStars; $i++)
  • Empty Star
  • @endfor

{{ $totalReviews.' '.get_phrase('Global Ratings') }}

    @foreach ($starCounts as $star => $count) @php // Calculate the percentage for each star rating $percentage = $totalReviews > 0 ? ($count / $totalReviews) * 100 : 0; @endphp
  • {{ get_phrase($star . ' Stars') }}
    {{ $count }}
  • @endforeach
@foreach($reviews as $review) @php $rating = round($review->rating); // Round the rating to the nearest integer $fullStars = $rating; // Number of full stars $emptyStars = 5 - $fullStars; // Remaining stars will be empty @endphp
{{ $review->review_to_user->name}}

{{ $review->created_at->format('d F Y') }}

    @for ($i = 0; $i < $fullStars; $i++)
  • Full Star
  • @endfor @for ($i = 0; $i < $emptyStars; $i++)
  • Empty Star
  • @endfor

{!! $review->review !!}

@endforeach
@if(Auth::check() && auth()->user()->role != 'admin') @php // Check if the booking exists $bookingExists = App\Models\TutorBooking::where('tutor_id', $tutor_details->id) ->where('student_id', auth()->user()->id) ->exists(); // Check if a review exists for this booking $existingReview = App\Models\TutorReview::where('tutor_id', $tutor_details->id) ->where('student_id', auth()->user()->id) ->first(); @endphp @if ($bookingExists)
@csrf

{{ get_phrase('Student Review') }}

@endif @endif