@extends('layouts.public.app') @section('title', @$supplier['company'] . ' Rating and Review | Chemical Wholesale') @section('description', 'Checkout ' . @$supplier['company'] . ' on Chemical Wholesale') @section('keywords', @$supplier['company'] ?: 'Chemical Wholesale, Rating and Review') @section('metaimage', @$supplier['getLogo']['path'] ? asset(@$supplier['getLogo']['path']) : asset('img/logo-lg2.png')) @section('content')
@include('public.supplier.supplier-page-header')
Rating and Reviews
Rate Supplier
@php $averageRating = @$reviews->avg('rating'); $filledStars = (int) $averageRating; $halfStar = $averageRating - $filledStars >= 0.5; @endphp
Total Reviews
{{ count(@$reviews) }} @if ($averageRating >= 4) Excellent @elseif ($averageRating >= 2) Good @else Satisfied @endif
This supplier total review(s)
Average Rating
{{ number_format(@$reviews->avg('rating'), 1) }} @for ($i = 1; $i <= 5; $i++) @if ($i <= $filledStars) @elseif ($i == $filledStars + 1 && $halfStar) @else @endif @endfor
This supplier total rating
@php $totalReviews = $reviews->count(); $ratingsCount = [ 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(), ]; $ratingPercentages = []; foreach ($ratingsCount as $rating => $count) { $ratingPercentages[$rating] = $totalReviews > 0 ? ($count / $totalReviews) * 100 : 0; } @endphp
@foreach ([5, 4, 3, 2, 1] as $rating)
{{ $rating }}
{{ number_format($ratingPercentages[$rating], 0) }}%
@endforeach
All Reviews
@if (count($reviews) == 0)

No supplier reviews. Rate or review this supplier ?

@endif @foreach ($reviews as $review)
img
@php $user = $review['getUser']['first_name'] . ' ' . $review['getUser']['last_name']; @endphp {{ trim($user) ?: 'User' }}
Total Spend: $1000
Total Review: 1
@for ($i = 1; $i <= 5; $i++) @endfor
{{ $review['created_at']->format('M d, Y') }}

{{ $review['review'] }}

@endforeach
@endsection @push('css') @endpush @push('js') @endpush