feat(checkout): track current cart purchase

This commit is contained in:
2026-08-21 14:05:33 -03:00
parent a34d5cba1a
commit afd69b8393
17 changed files with 258 additions and 23 deletions

View File

@@ -27,6 +27,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
'guest_token',
'status',
'origin',
'current_purchase_id',
])]
class Cart extends Model
{
@@ -43,6 +44,7 @@ class Cart extends Model
{
return [
'user_id' => 'integer',
'current_purchase_id' => 'integer',
];
}
@@ -76,6 +78,12 @@ class Cart extends Model
return $this->hasMany(Purchase::class, 'cart_id');
}
/** @return BelongsTo<Purchase, $this> */
public function currentPurchase(): BelongsTo
{
return $this->belongsTo(Purchase::class, 'current_purchase_id');
}
public function getTotalAmount(): float
{
$items = $this->relationLoaded('items')