@extends('admin.layouts.main') @section('content')

Customer Reviews for: {{ $product->product_name }}

{{-- Product Details Card --}}
Product Details

{{ $product->category ? $product->category->name : 'N/A' }}

{{ $product->brand ? $product->brand->name : 'N/A' }}

₹{{ number_format($product->sales_price, 2) }}

{{ $product->quantity }}

{{ $product->gst }}%

{{ $product->description }}

{{-- Product Images --}}
@foreach ([$product->product_image_1, $product->product_image_2, $product->product_image_3] as $image) @if ($image)
Product Image
@endif @endforeach
{{-- Customer Reviews Section --}}
Customer Reviews
@if ($reviews->count()) @php // Filter only visible reviews for average rating calculation $visibleReviews = $reviews->where('status', 1); $averageRating = round($visibleReviews->avg('rating'), 1); $totalVisibleReviews = $visibleReviews->count(); @endphp {{-- Average Rating Section --}}

{{ $averageRating }}

{{ $totalVisibleReviews }} Ratings & Reviews
Verified customers shared their experience
{{-- Review List --}}
@foreach ($reviews as $review)
{{-- User Info --}}
{{ substr($review->user ? $review->user->name : 'G', 0, 1) }}
{{ $review->user ? $review->user->name : 'Guest' }}
{{ $review->user ? $review->user->email : '' }}
{{-- Title & Content --}}
{{ $review->title }}

{{ Str::limit($review->description, 200) }}

{{-- Star Rating --}}
@for ($i = 1; $i <= 5; $i++) @endfor
{{-- Media Preview --}} @if ($review->media) @php $media = json_decode($review->media, true); @endphp
@foreach (array_slice($media, 0, 5) as $item) @php $extension = pathinfo($item, PATHINFO_EXTENSION); @endphp
@if (in_array($extension, ['jpg', 'jpeg', 'png', 'gif'])) Review Image @elseif(in_array($extension, ['mp4', 'mov', 'avi']))
@endif
@endforeach
@if (count($media) > 5) @endif @else No media @endif
{{-- Modal for showing/hiding review --}} @endforeach
@else
No reviews found for this product

Customers haven't reviewed this product yet.

@endif
{{ $reviews->links('pagination::bootstrap-5') }}
@endsection @section('script') @endsection @section('styles') @endsection