mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-23 15:41:24 +00:00
Update CartItemModel.php
This commit is contained in:
@@ -45,4 +45,15 @@ class CartItemModel extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(CartModel::class, 'cart_id');
|
return $this->belongsTo(CartModel::class, 'cart_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This will is the price of the CartItem as Money
|
||||||
|
*/
|
||||||
|
public function price(): Attribute
|
||||||
|
{
|
||||||
|
return new Attribute(
|
||||||
|
get: fn (int $value) => new Money($value),
|
||||||
|
set: fn (Money $value) => $value,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user