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()