From e0330b7b0fb3f701356db784444f0475978d6cc4 Mon Sep 17 00:00:00 2001 From: merdan Date: Thu, 4 May 2023 13:18:40 +0500 Subject: [PATCH] product detail --- packages/Sarga/API/Http/Controllers/Products.php | 6 +++++- packages/Sarga/API/Http/Resources/Catalog/ProductDetail.php | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/Sarga/API/Http/Controllers/Products.php b/packages/Sarga/API/Http/Controllers/Products.php index 8e2614d7b..9fb8f5b49 100644 --- a/packages/Sarga/API/Http/Controllers/Products.php +++ b/packages/Sarga/API/Http/Controllers/Products.php @@ -82,7 +82,11 @@ class Products extends ProductController public function testProduct($id){ $product = $this->productRepository->select('id','attribute_family_id','type','brand_id') - ->with(['brand','related_products'=> fn($rp) => $rp->select('id','type','attribute_family_id','brand_id')->with('brand'), + ->with(['brand','related_products'=> fn($rp) => $rp->select('id','type','attribute_family_id','brand_id') + ->with('brand') + ->whereHas('product_flat', function($qwh){ + $qwh->where('status',1); + }), 'variants' => function($query){ $query->whereHas('product_flat', function($qwh){ $qwh->where('status',1); diff --git a/packages/Sarga/API/Http/Resources/Catalog/ProductDetail.php b/packages/Sarga/API/Http/Resources/Catalog/ProductDetail.php index 86c09f806..4b73f35e6 100644 --- a/packages/Sarga/API/Http/Resources/Catalog/ProductDetail.php +++ b/packages/Sarga/API/Http/Resources/Catalog/ProductDetail.php @@ -25,8 +25,8 @@ class ProductDetail extends Product 'brand' => $product->brand->name ?? '', 'color' => $product->color, 'images' => ProductImage::collection($product->images), - 'color_variants' => ColorVariant::collection($this->related_products->where('status',true)), - 'size_variants' => SizeVariant::collection($this->variants->where('status',true)), + 'color_variants' => ColorVariant::collection($this->related_products), + 'size_variants' => SizeVariant::collection($this->variants), /* special price cases */ $this->merge($this->specialPriceInfo()),