Changeset View
Changeset View
Standalone View
Standalone View
src/app/Wallet.php
Show First 20 Lines • Show All 456 Lines • ▼ Show 20 Lines | class Wallet extends Model | ||||
* | * | ||||
* @param int $amount A amount of money (in cents) | * @param int $amount A amount of money (in cents) | ||||
* @param string $locale A locale for the output | * @param string $locale A locale for the output | ||||
* | * | ||||
* @return string String representation, e.g. "9.99 CHF" | * @return string String representation, e.g. "9.99 CHF" | ||||
*/ | */ | ||||
public function money(int $amount, $locale = 'de_DE') | public function money(int $amount, $locale = 'de_DE') | ||||
{ | { | ||||
$amount = round($amount / 100, 2); | return \App\Utils::money($amount, $this->currency, $locale); | ||||
$nf = new \NumberFormatter($locale, \NumberFormatter::CURRENCY); | |||||
$result = $nf->formatCurrency($amount, $this->currency); | |||||
// Replace non-breaking space | |||||
return str_replace("\xC2\xA0", " ", $result); | |||||
} | } | ||||
/** | /** | ||||
* The owner of the wallet -- the wallet is in his/her back pocket. | * The owner of the wallet -- the wallet is in his/her back pocket. | ||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||||
*/ | */ | ||||
public function owner() | public function owner() | ||||
▲ Show 20 Lines • Show All 255 Lines • Show Last 20 Lines |