parfum/app/Traits/Purchase/WithCalculateTotal.php
2025-10-30 19:29:18 +07:00

12 lines
204 B
PHP

<?php
namespace App\Traits\Purchase;
trait WithCalculateTotal
{
public function getTotal()
{
return $this->purchaseItems->sum(fn ($item) => $item->unit_price * $item->quantity);
}
}