parfum/app/Traits/Order/WithCalculateTotal.php

17 lines
343 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 - $item->discount);
}
}