@props(['ratings']) @php $starRatings = $ratings->whereNotNull('stars'); $thumbRatings = $ratings->whereNotNull('thumbs_up'); $average = $starRatings->count() ? round($starRatings->avg('stars'), 1) : null; $up = $thumbRatings->where('thumbs_up', true)->count(); $down = $thumbRatings->where('thumbs_up', false)->count(); @endphp

Community rating

Stars: {{ $average ? $average.'/5' : 'n/a' }} from {{ $starRatings->count() }} vote{{ $starRatings->count() === 1 ? '' : 's' }} | Thumbs: {{ $up }} up / {{ $down }} down

@foreach ($ratings->take(5) as $rating) @php $value = $rating->stars ? $rating->stars.'/5' : ($rating->thumbs_up === null ? 'no vote' : ($rating->thumbs_up ? 'thumbs up' : 'thumbs down')); @endphp

{{ $rating->user->name ?? 'User' }} | {{ $rating->category }} | {{ $value }} {{ $rating->body ? '- '.$rating->body : '' }}

@endforeach