(new CurrencyFormatService)->setRupiahFormat($value, true) ); } protected function discount(): Attribute { return Attribute::make( get:fn($value) => "{$value}%" ); } public function transaction() { return $this->belongsTo(Transaction::class); } public function laundry() { return $this->belongsTo(Laundry::class); } public function product() { return $this->belongsTo(Product::class); } public function totalPrice() { $price = $this->getRawOriginal('price') * $this->quantity; $totalPrice = $price - $price * ($this->getRawOriginal('discount') / 100); return $totalPrice; } public function totalPriceAsString() { return (new CurrencyFormatService)->setRupiahFormat($this->totalPrice()); } public function totalPriceAsFullString() { return (new CurrencyFormatService)->setRupiahFormat($this->totalPrice(), true); } }