Class · extends AbstractModel · implements CurrencyInterface
A currency.
| Name | Description |
|---|---|
DEFAULT_CURRENCY_ID |
| Type | Name | Description |
|---|---|---|
| `` | $timestamps |
public static function boot()public function scopeDefaultCurrency($query)public function scopeCode(Builder $query, string $code): Builderpublic function scopeDefaultSorting($query)Show default currency first, and all other currencies sorted by currency code.
Parameters
| Type | Name | Description |
|---|---|---|
Builder | $query |
Returns Builder
public static function validateCurrencyCode($currencyCode)public static function factoryForClientArea()public function convertTo(float $amount, Currency $currency): floatpublic static function convertBetween(CurrencyInterface $fromCurrency, float $amount, CurrencyInterface $toCurrency): floatConvert amount between currencies
Parameters
| Type | Name | Description |
|---|---|---|
CurrencyInterface | $fromCurrency | |
float | $amount | |
CurrencyInterface | $toCurrency |
Returns float
public function getCode(): stringpublic function setCode(string $code): selfpublic function getRate(): floatpublic function setRate(float $rate): selfpublic function nonFractionalCurrencyCodes(): arrayReturns string[]
public function isNonFractionalCurrency(): boolpublic function valueInCurrencyPrecision(float $amount): floatYield a value that reflects the Currency's support for fractional amounts. This makes no attempt to return a value that match the actual fractional precision for fraction supporting Currency. For example in the Currency is USD, and 1.666 is provided, 1.666 is returned. If the Currency is JPY for that same amount, 2.00 will be returned.
Note, even if this is a non-fractional currency, a float is returned for consistency.
Parameters
| Type | Name | Description |
|---|---|---|
float | $amount |
Returns float