mirror of
https://github.com/archtechx/money.git
synced 2025-12-12 03:14:03 +00:00
Update README.md
This commit is contained in:
parent
b57b9837a0
commit
0a1552b1f0
1 changed files with 16 additions and 2 deletions
18
README.md
18
README.md
|
|
@ -498,9 +498,9 @@ $money->is($bar); // true
|
||||||
|
|
||||||
## Tips
|
## Tips
|
||||||
|
|
||||||
### 💡 Accepted currency formats
|
### 💡 Accepted currency code formats
|
||||||
|
|
||||||
Most methods which accept a currency accept it in any format:
|
Most methods which accept a currency accept it in any of these formats:
|
||||||
```php
|
```php
|
||||||
currency(USD::class);
|
currency(USD::class);
|
||||||
currency(new USD);
|
currency(new USD);
|
||||||
|
|
@ -511,6 +511,20 @@ money(1000, 'USD')->convertTo(new CZK);
|
||||||
money(1000, new USD)->convertTo(CZK::class);
|
money(1000, new USD)->convertTo(CZK::class);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 💡 Dynamically add currencies
|
||||||
|
|
||||||
|
Class currencies are elegant, but not necessary. If your currency specs come from the database, or some API, you can register them as arrays.
|
||||||
|
|
||||||
|
```php
|
||||||
|
// LoadCurrencies middleware
|
||||||
|
|
||||||
|
currencies()->add(cache()->remember('currencies', 3600, function () {
|
||||||
|
return UserCurrencies::where('user_id', auth()->id())->get()->toArray();
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Where the DB call returns an array of array currencies following the [format mentioned above](#creating-a-currency).
|
||||||
|
|
||||||
## Development & contributing
|
## Development & contributing
|
||||||
|
|
||||||
Run all checks locally:
|
Run all checks locally:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue