A currency.

class Currency extends AbstractModel implements CurrencyInterface

Constants

DEFAULT_CURRENCY_ID

Properties summary

Type Property Description
protected $table
$timestamps
protected $fillable Define the fields that can be hydrated by a firstOrNew call.
integer $id
string $code
string $prefix
string $suffix
integer $format
float $rate
boolean $default

Methods summary

Return Type Method Name Description
static  boot() -
scopeDefaultCurrency($query) -
Builder scopeDefaultSorting(Builder $query) Show default currency first, and all other currencies sorted by currency code.
static  validateCurrencyCode($currencyCode) -
static  factoryForClientArea() -
float convertTo(float $amount, Currency $currency) -
static float convertBetween(CurrencyInterface $fromCurrency, float $amount, CurrencyInterface $toCurrency) Convert amount between currencies
string getCode() -
Currency setCode(string $code) -
float getRate() -
Currency setRate(float $rate) -

Details

static boot ()

scopeDefaultCurrency ($query)

Parameters

$query

Builder scopeDefaultSorting (Builder $query)

Show default currency first, and all other currencies sorted by currency code.

Parameters

Builder $query

Return Value

Builder

static validateCurrencyCode ($currencyCode)

Parameters

$currencyCode

static factoryForClientArea ()

float convertTo (float $amount, Currency $currency)

Parameters

float $amount
Currency $currency

Return Value

float

static float convertBetween (CurrencyInterface $fromCurrency, float $amount, CurrencyInterface $toCurrency)

Convert amount between currencies

Parameters

CurrencyInterface $fromCurrency
float $amount
CurrencyInterface $toCurrency

Return Value

float

string getCode ()

Return Value

string

Currency setCode (string $code)

Parameters

string $code

Return Value

Currency

float getRate ()

Return Value

float

Currency setRate (float $rate)

Parameters

float $rate

Return Value

Currency