parfum/app/Traits/Order/WithCalculateTotal.php
2025-11-11 01:41:10 +07:00

17 lines
391 B
PHP

<?php
namespace App\Traits\Order;
trait WithCalculateTotal
{
public function getSubTotal()
{
return $this->items->sum(fn ($item) => $item->unit_price * $item->quantity);
}
public function getTotal()
{
return $this->items->sum(fn ($item) => $item->unit_price * $item->quantity - replaceCurrency($this->form->discount) - $this->voucherDiscount);
}
}