@extends('layouts.front.home') @section('title') {{ __('products.products_title') }} @endsection @section('css') @endsection @section('content')
@isset($product)
{{ $product?->category->name }}
Thumbnail 1 @foreach ($product->imgs as $i => $img) @if (!$img == "") Thumbnail {{ $i+2 }} @endif @endforeach

{{ $product->name }}

{{ $product?->category->name }} {{ substr(number_format((float) $product->ratings_avg_rating, 1, '.', ''), 0) }} ({{ count($product?->ratings) }})

{{ $product->desc }}

{{ __('products.stock_status') }}: {{ $product->stock_quantity }} {{ __('products.units_available') }}
Supplier avatar
{{ $product?->provider?->name }}
{{ $product?->provider?->location }}
{{--
Starting price
--}}
{{ $product->price }} {{ __('products.currency_sar') }}
{{ __('products.imaging_type') }}: {{ $product->imaging_type }}
{{ __('products.power') }}: {{ $product->power }}
{{ __('products.weight') }}: {{ $product->weight }}
{{ __('products.dimensions') }}: {{ $product->dimensions }}
{{ __('products.warranty') }}: {{ $product->warranty }}
{{ __('products.origin') }}: {{ $product->origin?->name ?? '' }}
{{ substr(number_format((float) $product->ratings_avg_rating, 1, '.', ''), 0) }}
({{ count($product?->ratings) }}) {{ __('products.reviews') }}
@php $total = max(1, $product->ratings->count()); $counts = $product->ratings->groupBy('rating')->map->count(); $dist = collect([5,4,3,2,1])->map(function ($star) use ($counts, $total) { $count = (int) ($counts[$star] ?? 0); $pct = round(($count / $total) * 100); return ['count' => $count, 'pct' => $pct]; })->keyBy(function($v,$k){ return [5,4,3,2,1][$k]; }); $raw_ratings_avg_rating = (float) (substr(number_format((float) $product->ratings_avg_rating, 1, '.', ''), 0) ?? 0); $val_ratings_avg_rating = (int) round( max(0, min(5, $raw_ratings_avg_rating)) ); @endphp
{{-- --}} @for ($i = 0; $i < $val_ratings_avg_rating; $i++) @endfor @for ($i = 0; $i < 5 - $val_ratings_avg_rating; $i++) @endfor
{{--
5
80%
4
72%
3
50%
2
21%
1
10%
--}} @foreach ([5,4,3,2,1] as $star)
{{ $star }}
{{ $dist[$star]['pct'] ?? 0 }}%
@endforeach
@foreach ($product->top_rating as $rating) @php $user = $rating?->user; $raw = (float) ($rating->rating ?? 0); $val = (int) round( max(0, min(5, $raw)) ); @endphp
{{-- --}} @for ($i = 0; $i < $val; $i++) @endfor @for ($i = 0; $i < 5 - $val; $i++) @endfor
{{--
{{ $rating?->user->name }}
--}}

{{ $rating->comment }}

avatar
{{ $user?->name }} {{ $user?->location }}
@endforeach
{{ __('products.explore_similar') }} {{ __('products.products') }}
@foreach ($product->related_products as $related)
{{-- Digital X-Ray --}}
{{ $related->name }} @if (is_null($related->is_favorite)) @else @endif
{{ $related->name }}
{{ $product?->category->name }}
{{ substr(number_format((float) $related->ratings_avg_rating, 1, '.', ''), 0) }}

{{ $related->desc }}

{{ $related->price }} {{ __('products.currency_sar') }} {{ __('products.details') }}
@endforeach
@endisset
@endsection @section('script') @endsection