<?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);
    }
}
