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,