@extends('layouts.customer') @section('title',$product->name) @section('content')
Collection/ {{$product->category->name}}/ {{$product->user->shop->shop_name}}/ {{$product->name}}
@if($product->images->count() > 1) @else @endif
@if($product->images->count() > 1)
@foreach($product->images as $key => $image) @if($key > 0)
@endif @endforeach
@endif

{{$product->name}}
@php $overallRating = $product->ratings->avg('product_rating'); @endphp

@for ($i = 1; $i <= 5; $i++) @if ($i <= round($overallRating)) @else @endif @endfor ({{ number_format($overallRating, 1) }} out of 5)

{{ $ratings->count() }} ratings


{{ $product->user->shop->shop_name }}
{{ $product->user->email }}
{{ $product->user->phone }}
{{ $product->user->shop->barangay }}
{{ $product->user->shop->municipal }}
Report Abuse @if (Auth::check()) Chat @else Chat @endif

@if($product->productPrices->isNotEmpty()) @php // Fetch the latest active price $latestActivePrice = $product->productPrices() ->where('is_active', 1) ->latest('created_at') ->first(); // Fetch the previous active price $previousActivePrice = null; if ($latestActivePrice) { $previousActivePrice = $product->productPrices() ->where('is_active', 1) ->where('created_at', '<', $latestActivePrice->created_at) ->latest('created_at') ->first(); } // Calculate the discount $discountedPrice = $latestActivePrice ? $latestActivePrice->price : null; $originalPrice = $previousActivePrice ? $previousActivePrice->price : null; $discountPercent = $originalPrice && $discountedPrice ? (($originalPrice - $discountedPrice) / $originalPrice) * 100 : null; @endphp @if($discountedPrice && $discountPercent > 0) ₱ {{ number_format($discountedPrice, 2, '.', ',') }} @if($originalPrice) ₱ {{ number_format($originalPrice, 2, '.', ',') }} @endif ({{ number_format($discountPercent, 2) }}% off) @else ₱ {{ number_format($discountedPrice, 2, '.', ',') }} @endif @endif

{!! $product->description !!}

{!! $product->small_description !!}


@if($product->qty > 0) @else @endif @if ($product->qty <= 10)

only {{$product->qty}} left in stock!

@endif
@if($product->qty > 0) @endif

Product Ratings

@if ($ratings->isEmpty())

No ratings available for this product.

@else
    @foreach ($ratings as $rating)
  • Customer:
    {{ $rating->user->name }}
    Product Rating:
    @for ($i = 1; $i <= 5; $i++) @if ($i <= $rating->product_rating) @else @endif @endfor
    Comment:
    {{ $rating->comment }}
    @if ($rating->images && $rating->images->isNotEmpty())
    @foreach ($rating->images as $image)
    Rating Image
    @endforeach
    @endif
  • @endforeach
@if ($ratings->count() > 5) @endif @endif
@endsection @section('scripts') @endsection