feat(checkout): track current cart purchase
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user