@@ 5-24 (lines=20) @@ | ||
2 | ||
3 | use PHPViet\Laravel\NumberToWords\N2WFacade; |
|
4 | ||
5 | if (! function_exists('n2w')) { |
|
6 | ||
7 | /** |
|
8 | * Hàm hổ trợ chuyển đổi số sang chữ số. |
|
9 | * |
|
10 | * @param int|float $number |
|
11 | * @param string|null $dictionary |
|
12 | * @return string |
|
13 | */ |
|
14 | function n2w($number, string $dictionary = null): string |
|
15 | { |
|
16 | $currentDictionary = N2WFacade::$dictionary; |
|
17 | N2WFacade::$dictionary = $dictionary; |
|
18 | $result = N2WFacade::toWords($number); |
|
19 | N2WFacade::$dictionary = $currentDictionary; |
|
20 | ||
21 | return $result; |
|
22 | } |
|
23 | } |
|
24 | ||
25 | if (! function_exists('n2c')) { |
|
26 | ||
27 | /** |
|
@@ 25-45 (lines=21) @@ | ||
22 | } |
|
23 | } |
|
24 | ||
25 | if (! function_exists('n2c')) { |
|
26 | ||
27 | /** |
|
28 | * Hàm hổ trợ chuyển đổi số sang tiền tệ. |
|
29 | * |
|
30 | * @param $number |
|
31 | * @param string|null $dictionary |
|
32 | * @param null|string|array $unit |
|
33 | * @return string |
|
34 | */ |
|
35 | function n2c($number, $unit = 'đồng', string $dictionary = null): string |
|
36 | { |
|
37 | $currentDictionary = N2WFacade::$dictionary; |
|
38 | N2WFacade::$dictionary = $dictionary; |
|
39 | $result = N2WFacade::toCurrency($number, $unit); |
|
40 | N2WFacade::$dictionary = $currentDictionary; |
|
41 | ||
42 | return $result; |
|
43 | } |
|
44 | } |
|
45 |