17 lines
402 B
PHP
17 lines
402 B
PHP
<?php
|
|
|
|
namespace App\Traits\Order;
|
|
|
|
trait WithCalculateTotal
|
|
{
|
|
public function getSubTotal(): int
|
|
{
|
|
return $this->items->sum(fn ($item) => $item->unit_price * $item->quantity);
|
|
}
|
|
|
|
public function getTotal(): int
|
|
{
|
|
return $this->items->sum(fn ($item) => $item->unit_price * $item->quantity - parseRupiahToInt($this->form->discount) - $this->voucherDiscount);
|
|
}
|
|
}
|