From a29245b5d4012d248bdcafffe27399280ba1c4b1 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Fri, 2 Jun 2023 14:38:45 +0800 Subject: [PATCH] Fixed flex service. --- beike/Shop/Services/TotalService.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/beike/Shop/Services/TotalService.php b/beike/Shop/Services/TotalService.php index 0ae10206..0b25edf0 100644 --- a/beike/Shop/Services/TotalService.php +++ b/beike/Shop/Services/TotalService.php @@ -138,13 +138,34 @@ class TotalService return collect($carts)->sum('subtotal'); } - public function getCartProducts() + /** + * Get Cart Products + * + * @return array + */ + public function getCartProducts(): array { return $this->cartProducts; } + /** + * Get Current Cart + * + * @return Cart + */ public function getCurrentCart() { return $this->currentCart; } + + /** + * Get Cart Product Amount + * + * @return mixed + */ + public function countProducts(): mixed + { + $cartProducts = $this->getCartProducts(); + return collect($cartProducts)->sum('quantity'); + } }