Skip to content

Commit c720e78

Browse files
[11.x] feat: document new Number::withCurrency and Number::useCurrency (#9936)
* feat: document new currency methods * feat: document new currency methods
1 parent f6715ca commit c720e78

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

helpers.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct
103103
[Number::trim](#method-number-trim)
104104
[Number::useLocale](#method-number-use-locale)
105105
[Number::withLocale](#method-number-with-locale)
106+
[Number::useCurrency](#method-number-use-currency)
107+
[Number::withCurrency](#method-number-with-currency)
106108

107109
</div>
108110

@@ -1425,6 +1427,32 @@ The `Number::withLocale` method executes the given closure using the specified l
14251427
return Number::format(1500);
14261428
});
14271429

1430+
<a name="method-number-use-currency"></a>
1431+
#### `Number::useCurrency()` {.collection-method}
1432+
1433+
The `Number::useCurrency` method sets the default number currency globally, which affects how the currency is formatted by subsequent invocations to the `Number` class's methods:
1434+
1435+
use Illuminate\Support\Number;
1436+
1437+
/**
1438+
* Bootstrap any application services.
1439+
*/
1440+
public function boot(): void
1441+
{
1442+
Number::useCurrency('GBP');
1443+
}
1444+
1445+
<a name="method-number-with-currency"></a>
1446+
#### `Number::withCurrency()` {.collection-method}
1447+
1448+
The `Number::withCurrency` method executes the given closure using the specified currency and then restores the original currency after the callback has executed:
1449+
1450+
use Illuminate\Support\Number;
1451+
1452+
$number = Number::withCurrency('GBP', function () {
1453+
// ...
1454+
});
1455+
14281456
<a name="paths"></a>
14291457
## Paths
14301458

0 commit comments

Comments
 (0)