From c29cf811fc52a4da0022509e5487f99628f871ff Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Mon, 29 Aug 2022 16:43:02 +0800 Subject: [PATCH] fixed active --- beike/Shop/Http/Controllers/ProductController.php | 7 ------- beike/Shop/Http/Resources/ProductDetail.php | 1 + 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/beike/Shop/Http/Controllers/ProductController.php b/beike/Shop/Http/Controllers/ProductController.php index e186b1b9..0889938f 100644 --- a/beike/Shop/Http/Controllers/ProductController.php +++ b/beike/Shop/Http/Controllers/ProductController.php @@ -19,13 +19,6 @@ class ProductController extends Controller public function show(Request $request, Product $product) { $product = ProductRepo::getProductDetail($product); - if ($product->active == 0) { - $data = [ - 'product' => (new ProductDetail($product))->jsonSerialize(), - 'error' => trans('product.has_been_inactive') - ]; - return view('product', $data); - } $data = [ 'product' => (new ProductDetail($product))->jsonSerialize(), ]; diff --git a/beike/Shop/Http/Resources/ProductDetail.php b/beike/Shop/Http/Resources/ProductDetail.php index daf10a6c..f70cc0b3 100644 --- a/beike/Shop/Http/Resources/ProductDetail.php +++ b/beike/Shop/Http/Resources/ProductDetail.php @@ -36,6 +36,7 @@ class ProductDetail extends JsonResource 'variables' => $this->decodeVariables($this->variables), 'skus' => SkuDetail::collection($this->skus)->jsonSerialize(), 'in_wishlist' => $this->inCurrentWishlist->id ?? 0, + 'active' => (bool)$this->active, ]; }