From 46d38c0ccec68baade24008f6a35ea193472f350 Mon Sep 17 00:00:00 2001 From: TL Date: Wed, 20 Jul 2022 11:13:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beike/Models/Product.php | 1 + beike/Shop/Http/Resources/ProductDetail.php | 2 +- beike/Shop/Http/Resources/SkuDetail.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/beike/Models/Product.php b/beike/Models/Product.php index 80fd0d9b..a6be47e9 100644 --- a/beike/Models/Product.php +++ b/beike/Models/Product.php @@ -17,6 +17,7 @@ class Product extends Model ]; protected $casts = [ 'active' => 'boolean', + 'variables' => 'array', ]; public function categories() diff --git a/beike/Shop/Http/Resources/ProductDetail.php b/beike/Shop/Http/Resources/ProductDetail.php index 1dd883d7..caa97164 100644 --- a/beike/Shop/Http/Resources/ProductDetail.php +++ b/beike/Shop/Http/Resources/ProductDetail.php @@ -23,7 +23,7 @@ class ProductDetail extends JsonResource 'description' => $this->description->description ?? '', 'image' => image_resize($this->image), 'category_id' => $this->category_id ?? null, - 'variables' => json_decode($this->variables), + 'variables' => $this->variables, 'skus' => SkuDetail::collection($this->skus)->jsonSerialize(), ]; } diff --git a/beike/Shop/Http/Resources/SkuDetail.php b/beike/Shop/Http/Resources/SkuDetail.php index 635d32e3..dd142f04 100644 --- a/beike/Shop/Http/Resources/SkuDetail.php +++ b/beike/Shop/Http/Resources/SkuDetail.php @@ -19,7 +19,7 @@ class SkuDetail extends JsonResource { return [ 'id' => $this->id, - 'variants' => json_decode($this->varians), + 'variants' => $this->variants, 'position' => $this->position, 'image' => image_resize($this->image), 'model' => $this->model,