Skip to content

Commit 46ec680

Browse files
committed
added default convert option to config
1 parent 058cfb5 commit 46ec680

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

config/money.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
'defaults' => [
66

7-
'currency' => env('MONEY_DEFAULTS_CURRENCY', 'USD'),
7+
'currency' => env('MONEY_DEFAULTS_CURRENCY', 'USD'),
8+
9+
'convert' => env('MONEY_DEFAULTS_CONVERT', false),
810

911
],
1012

src/helpers.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
use Akaunting\Money\Money;
55

66
if (! function_exists('money')) {
7-
function money(mixed $amount, string $currency = null, bool $convert = false): Money
7+
function money(mixed $amount, string $currency = null, bool $convert = null): Money
88
{
99
if (is_null($currency)) {
1010
/** @var string $currency */
1111
$currency = config('money.defaults.currency');
1212
}
1313

14+
if (is_null($convert)) {
15+
/** @var bool $convert */
16+
$convert = config('money.defaults.convert');
17+
}
18+
1419
return new Money($amount, currency($currency), $convert);
1520
}
1621
}

0 commit comments

Comments
 (0)