protected function amount(): Attribute
{
return Attribute::make(
get: function () {
return $this?->products->map(
fn ($product) => $product->pivot->quantity * $product->pivot->unit_price
)->sum();
},
);
}
protected function amount(): Attribute
{
return Attribute::make(
get: function () {
return $this?->products->map(
fn ($product) => $product->pivot->quantity * $product->pivot->unit_price
)->sum();
},
);
}