@extends('layouts.app') @section('content')
@php $primaryImage = $product->getPrimaryImage(); $hasImages = $product->productImages()->count() > 0; @endphp @if($hasImages && $primaryImage) {{ $product->name }} @elseif($product->image) {{ $product->name }} @else No Image Available @endif
@if($hasImages && $product->productImages()->count() > 1)
@foreach($product->productImages as $image) Product Image @endforeach
@endif
@if($product->category) {{ $product->category->name }} @endif @if($product->brand) {{ $product->brand->name }} @endif

{{ $product->name }}

@if($product->rating && $product->rating > 0)
@for($i = 0; $i < floor($product->rating); $i++) @endfor @if($product->rating % 1 != 0) @endif ({{ number_format($product->rating, 1) }} out of 5)
@endif
@if($product->inventory && $product->inventory->quantity > 0) In Stock ({{ $product->inventory->quantity }} available) @else Out of Stock @endif

{{ \App\Support\Currency::symbol() }}{{ number_format($product->price, 2) }}

@if($product->cost_price && $product->cost_price < $product->price)

{{ \App\Support\Currency::symbol() }}{{ number_format($product->cost_price, 2) }} Save {{ round(((($product->price - $product->cost_price) / $product->price) * 100)) }}%

@endif
@if($product->weight) @endif @if($product->dimensions) @endif
SKU: {{ $product->sku }}
Weight: {{ $product->weight }} kg
Dimensions: {{ $product->dimensions }}
inventory || $product->inventory->quantity <= 0) disabled @endif>
Share:

{{ $product->description ?? 'No description available.' }}

@if($product->specification)
{!! nl2br($product->specification) !!}
@else

No specifications available.

@endif
@if($relatedProducts->count() > 0)

Related Products

@foreach($relatedProducts as $related)
{{ $related->name }} @if($related->inventory && $related->inventory->quantity > 0) In Stock @else Out of Stock @endif
{{ Str::limit($related->name, 50) }}

{{ \App\Support\Currency::symbol() }}{{ number_format($related->price, 2) }}

View Details
@endforeach
@endif

Customer Reviews

@if(auth()->check()) @php $hasPurchased = auth()->user()->orders() ->join('order_items', 'orders.id', '=', 'order_items.order_id') ->where('order_items.product_id', $product->id) ->where('orders.status', '!=', 'cancelled') ->exists(); @endphp @if($hasPurchased)
Write a Review
@if($errors->any())
    @foreach($errors->all() as $error)
  • {{ $error }}
  • @endforeach
@endif
@csrf
@for($i = 5; $i >= 1; $i--) @endfor
Select your rating (1-5 stars)
@error('title')
{{ $message }}
@enderror
0/1000 characters @error('content')
{{ $message }}
@enderror
@else
You can only review products you have purchased. View your orders
@endif @else
Sign in to write a review.
@endif @if($product->reviews()->approved()->count() > 0)
@foreach($product->reviews()->approved()->latest()->paginate(5) as $review)
@for($i = 0; $i < $review->rating; $i++) @endfor @for($i = $review->rating; $i < 5; $i++) @endfor
{{ $review->title }}

{{ $review->user->name }} • {{ $review->created_at->diffForHumans() }}

@if(auth()->check() && (auth()->user()->id === $review->user_id || auth()->user()->is_admin))
@csrf @method('DELETE')
@endif

{{ $review->content }}

@endforeach
{{ $product->reviews()->approved()->latest()->paginate(5)->links() }}
@else
No reviews yet. Be the first to review this product!
@endif
@endsection