Skip to content

Commit bdfa7a2

Browse files
committed
Rewritten config file
1 parent 897ce63 commit bdfa7a2

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

src/MoneyServiceProvider.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ public function boot()
1313
$this->registerPublishing();
1414

1515
try {
16-
Money::set(' ', '.', 1, false, Currency::code('RUB'));
16+
Money::set(
17+
config('money.thousands_separator', ' '),
18+
config('money.decimal_separator', '.'),
19+
config('money.decimals', 1),
20+
config('money.ends_with_0', false),
21+
Currency::code(config('money.default_currency', 'RUB'))
22+
);
1723
} catch (CurrencyDoesNotExistException | ShouldPublishConfigFileException $e) {
1824
dd($e->getMessage());
1925
}

src/config/money.php

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,61 @@
11
<?php
22

33
return [
4-
'default_currency' => 'RUB',
4+
/*
5+
|--------------------------------------------------------------------------
6+
| Default currency
7+
|--------------------------------------------------------------------------
8+
|
9+
| This option controls the default currency of the package when user
10+
| doesn't provide any currency in methods. The default one will be
11+
| chosen from this option.
12+
| The code of the currency must be provided: USD, EUR, RUB, ...
13+
|
14+
*/
15+
'default_currency' => 'USD',
16+
17+
/*
18+
|--------------------------------------------------------------------------
19+
| Thousands separator
20+
|--------------------------------------------------------------------------
21+
|
22+
| This option controls the default separator between thousands
23+
| like 1( )000( )000.
24+
|
25+
*/
26+
'thousands_separator' => ' ',
27+
28+
/*
29+
|--------------------------------------------------------------------------
30+
| Decimal separator
31+
|--------------------------------------------------------------------------
32+
|
33+
| This option controls the default separator between decimals
34+
| like 123(.)4.
35+
|
36+
*/
37+
'decimal_separator' => '.',
38+
39+
/*
40+
|--------------------------------------------------------------------------
41+
| Number of digits after decimal
42+
|--------------------------------------------------------------------------
43+
|
44+
| This option controls the default number of digits after
45+
| the decimal separator like 123.(4)
46+
|
47+
*/
48+
'decimals' => 1,
49+
50+
/*
51+
|--------------------------------------------------------------------------
52+
| Ends with 0
53+
|--------------------------------------------------------------------------
54+
|
55+
| This option controls whether a money string ends with 0 or not.
56+
| When true is provided: 123()
57+
| When false is provided: 123(.0)
58+
|
59+
*/
60+
'ends_with_0' => false
561
];

0 commit comments

Comments
 (0)