@extends('layouts.app') @section('content')
Home / Shop / {{ $product->name }}
{{ $product->name }} @if($product->is_featured)
Best Seller
@endif
@if($product->gallery->count() > 0)
@foreach($product->gallery as $img) @endforeach
@endif

{{ $product->name }}

@if($product->regular_price && $product->regular_price > $product->price) LKR {{ number_format($product->price, 2) }} LKR {{ number_format($product->regular_price, 2) }} @else LKR {{ number_format($product->price, 2) }} @endif
@php $approvedReviews = $product->reviews->where('is_approved', true); $reviewCount = $approvedReviews->count(); $avgRating = $reviewCount > 0 ? $approvedReviews->avg('rating') : 0; $fullStars = floor($avgRating); $halfStar = $avgRating - $fullStars >= 0.5; $emptyStars = 5 - $fullStars - ($halfStar ? 1 : 0); @endphp
@for($i=0; $i<$fullStars; $i++) @endfor @if($halfStar) @endif @for($i=0; $i<$emptyStars; $i++) @endfor ({{ $reviewCount }} Reviews)

{{ Str::limit($product->description, 150) }}

@if($product->type === 'variable')
@foreach($product->attributes as $attribute)
{{ $attribute->name }}
@foreach($attribute->values as $value) @endforeach
@endforeach
@endif

Guaranteed Safe Checkout

Pay in 3 with Koko Interest-free installments
Pay via Koko
PayHere

Description

{!! nl2br(e($product->description)) !!}

Reviews ({{ $product->reviews->where('is_approved', true)->count() }})

@auth

Write a Review

@if ($errors->any())
Whoops! There were some problems with your input.
    @foreach ($errors->all() as $error)
  • {{ $error }}
  • @endforeach
@endif @if(session('success'))
{{ session('success') }}
@endif
@csrf
@error('rating') {{ $message }} @enderror

Click a star to rate.

@error('review') {{ $message }} @enderror
@else

Please login to write a review.

@endauth
@forelse($product->reviews->where('is_approved', true) as $review)
@for($i=0; $i<$review->rating; $i++) @endfor
{{ $review->user->name }} - {{ $review->created_at->format('M d, Y') }}

{{ $review->review }}

@empty

No reviews yet. Be the first to review this product!

@endforelse

You May Also Like

@foreach($relatedProducts as $related)

{{ $related->name }}

@if($related->regular_price && $related->regular_price > $related->price) LKR {{ number_format($related->price, 2) }} LKR {{ number_format($related->regular_price, 2) }} @else LKR {{ number_format($related->price, 2) }} @endif
@endforeach
@if($relatedProducts->isEmpty())

No related products found.

@endif
@endsection