作者 何书鹏

删除购物车失效数据

... ... @@ -33,6 +33,13 @@ class Cart extends Model
$cartData = self::with('goods,sku_price')->where([
'user_id' => $user->id
])->select();
// 删除失效数据
foreach ($cartData as $v){
if(!$v->goods || !$v->sku_price){
$v->delete();
}
}
return $cartData;
}
... ...