'integer', 'product_id' => 'integer', 'quantity' => 'decimal:2', ]; /** * 归属用户 */ public function user(): BelongsTo { return $this->belongsTo(UserModel::class, 'user_id', 'id'); } /** * 购物车商品(软删除后为 null;列表接口需 withTrashed 自行判断状态) */ public function product(): BelongsTo { return $this->belongsTo(ProductModel::class, 'product_id', 'id'); } }