belongsTo(Currency::class); } /** * Set exchange value. * * @return void */ public function setAmountAttribute($value) { $this->attributes['amount'] = MoneyHelper::parseInput($value, $this->currency); } /** * Get exchange value. * * @return string|null */ public function getAmountAttribute(): ?string { if (! ($amount = Arr::get($this->attributes, 'amount', null))) { return null; } return MoneyHelper::exchangeValue($amount, $this->currency); } /** * Get value of amount (without currency). * * @return string */ public function getValueAttribute(): string { if (! ($amount = Arr::get($this->attributes, 'amount', null))) { return ''; } return MoneyHelper::getValue($amount, $this->currency); } /** * Get display value: amount with currency. * * @return string */ public function getDisplayValueAttribute(): string { if (! ($amount = Arr::get($this->attributes, 'amount', null))) { return ''; } return MoneyHelper::format($amount, $this->currency); } }