amount < 0) { throw new InvalidArgumentException('Money cannot be negative.'); } } /** * Format the bytes into a human-readable string. */ public function format(string $currency = 'IDR'): string { $format = new NumberFormatter(app()->getLocale(), NumberFormatter::CURRENCY); return $format->formatCurrency($this->amount, $currency); } /** * Automatically format when echoed in Blade (e.g., {{ $model->amount }}). */ public function __toString(): string { return $this->format(); } }