diff --git a/beike/Shop/Http/Resources/CartList.php b/beike/Shop/Http/Resources/CartList.php index 14fb0546..713eae99 100644 --- a/beike/Shop/Http/Resources/CartList.php +++ b/beike/Shop/Http/Resources/CartList.php @@ -18,10 +18,12 @@ class CartList extends JsonResource { $sku = $this->sku; $price = $sku->price; + $description = $sku->product->description; $subTotal = $price * $this->quantity; return [ 'product_id' => $this->product_id, 'sku_id' => $this->product_sku_id, + 'name' => $description->name, 'image' => image_resize($sku->image), 'price' => $price, 'price_format' => currency_format($price), diff --git a/beike/Shop/Services/CartService.php b/beike/Shop/Services/CartService.php index 3d051947..6619257f 100644 --- a/beike/Shop/Services/CartService.php +++ b/beike/Shop/Services/CartService.php @@ -21,7 +21,10 @@ class CartService if (empty($customer)) { return []; } - $cartItems = Cart::query()->where('customer_id', $customer->id)->get(); + $cartItems = Cart::query() + ->with(['sku.product.description']) + ->where('customer_id', $customer->id) + ->get(); $cartList = CartList::collection($cartItems)->jsonSerialize(); return $cartList; }