@extends('layouts.admin') @section('title', 'Data Ulasan | Admin Rental') @section('page_title', 'Data Ulasan') @push('styles') @endpush @section('content') @php // Helper function to render star rating $renderStars = function ($rating) { $fullStars = (int) $rating; $hasHalf = ($rating - $fullStars) >= 0.5; $emptyStars = 5 - $fullStars - ($hasHalf ? 1 : 0); $html = ''; for ($i = 0; $i < $fullStars; $i++) { $html .= ''; } if ($hasHalf) { $html .= ''; } for ($i = 0; $i < $emptyStars; $i++) { $html .= ''; } return $html; }; // Calculate summary statistics $totalReviews = $reviews->count(); $averageRating = $reviews->count() > 0 ? round($reviews->avg('rating'), 1) : 0; $highRatingCount = $reviews->filter(fn ($r) => $r->rating >= 4)->count(); $thisMonthCount = $reviews->filter(fn ($r) => \Carbon\Carbon::parse($r->created_at)->isCurrentMonth())->count(); @endphp
Admin Rental Data Ulasan
@if ($message = Session::get('success'))
Berhasil

{{ $message }}

@endif @if ($message = Session::get('error'))
Gagal

{{ $message }}

@endif

Data Ulasan

Pantau ulasan dan rating dari customer untuk kendaraan dan layanan rental Anda.

Total Ulasan

{{ $totalReviews }}

Rata-rata Rating

{{ $averageRating }}/5

Rating Tinggi (4-5)

{{ $highRatingCount }}

Bulan Ini

{{ $thisMonthCount }}

Reset
@if ($reviews && $reviews->count() > 0)
@foreach ($reviews as $index => $review) @php $ratingClass = match ((int) $review->rating) { 5 => 'is-excellent', 4 => 'is-good', 3 => 'is-average', 2 => 'is-poor', default => 'is-terrible', }; @endphp @endforeach
No Tanggal Customer Kendaraan Booking Code Rating Ulasan Aksi
{{ ($reviews->firstItem() ?? 1) + $index }} {{ \Carbon\Carbon::parse($review->created_at)->format('d M Y H:i') }} {{ $review->customer?->name ?? '-' }} {{ $review->vehicle?->name ?? '-' }} {{ $review->booking?->booking_code ?? '-' }}
{!! $renderStars($review->rating) !!}
{{ $review->rating }}/5
{{ \Illuminate\Support\Str::limit($review->review ?? 'Tanpa komentar', 100) }}
@if ($review->customer) Customer @endif @if ($review->booking) Booking @endif
@if ($reviews->hasPages())
{{ $reviews->links() }}
@endif @else

Belum Ada Ulasan

Ulasan dari customer akan muncul di halaman ini setelah booking selesai dan review dikirimkan.

@endif
@endsection