From ede12992c83faa8d8fb3391747269f883c26bc52 Mon Sep 17 00:00:00 2001 From: weigang Date: Sun, 13 Sep 2020 16:26:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=B4=AD=E7=89=A9=E8=BD=A6?= =?UTF-8?q?=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/v3/Goods.php | 3 ++- app/Model/v3/GoodsActivity.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Model/v3/Goods.php b/app/Model/v3/Goods.php index c1f971c..b43d946 100644 --- a/app/Model/v3/Goods.php +++ b/app/Model/v3/Goods.php @@ -100,7 +100,8 @@ class Goods extends Model public function getCartNumAttribute() { - return 0; + $userId = $this->request->user->id ?? 0; + return $userId ? (integer)$this->shopCartService->check($userId, $this->id,1) : 0; } public function getIsEffectiveAttribute() diff --git a/app/Model/v3/GoodsActivity.php b/app/Model/v3/GoodsActivity.php index bb78d70..a9bb3b2 100644 --- a/app/Model/v3/GoodsActivity.php +++ b/app/Model/v3/GoodsActivity.php @@ -68,7 +68,8 @@ class GoodsActivity extends Model public function getCartNumAttribute() { - return 0; + $userId = $this->request->user->id ?? 0; + return $userId ? (integer)$this->shopCartService->check($userId, $this->id,1) : 0; } public function getIsEffectiveAttribute()