Skip to content

Commit 0ea9a4c

Browse files
committed
fix: mergeConfigFrom is not loaded
1 parent da3c2e0 commit 0ea9a4c

File tree

3 files changed

+10
-36
lines changed

3 files changed

+10
-36
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ Cài đặt Laravel Number To Words thông qua [Composer](https://getcomposer.or
2626
composer require phpviet/laravel-number-to-words
2727
```
2828

29-
Publish file cấu hình thông qua câu lệnh:
30-
31-
```php
32-
php artisan vendor:publish --provider="PHPViet\Laravel\NumberToWords\ServiceProvider" --tag="config"
33-
```
34-
3529
## Cách sử dụng
3630

3731
### Các tính năng của extension:
@@ -105,7 +99,13 @@ n2c(9492.15, ['đô', 'xen']);
10599

106100
> Nếu như bạn cảm thấy cách đọc ở trên ổn rồi thì hãy bỏ qua bước này.
107101
108-
Đầu tiên, bạn mở file config `config/n2w.php` như sau:
102+
Đầu tiên để thay đổi cách đọc số bạn cần phải publish file cấu hình thông qua câu lệnh:
103+
104+
```php
105+
php artisan vendor:publish --provider="PHPViet\Laravel\NumberToWords\ServiceProvider" --tag="config"
106+
```
107+
108+
Sau khi publish xong ta sẽ có được file config `config/n2w.php` như sau:
109109

110110
```php
111111
return [
@@ -207,6 +207,6 @@ N2W::toWords(15);
207207

208208
## Dành cho nhà phát triển
209209

210-
Nếu như bạn cảm thấy extension còn thiếu sót hoặc sai sót và bạn muốn đóng góp để phát triển chung,
211-
chúng tôi rất hoan nghênh! Hãy tạo các `issue` để đóng góp ý tưởng cho phiên bản kế tiếp
210+
Nếu như bạn cảm thấy extension còn thiếu sót hoặc sai sót và bạn muốn đóng góp để phát triển chung,
211+
chúng tôi rất hoan nghênh! Hãy tạo các `issue` để đóng góp ý tưởng cho phiên bản kế tiếp
212212
hoặc tạo `PR` để đóng góp. Cảm ơn!

src/N2WFacade.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Illuminate\Support\Facades\Facade;
1212
use InvalidArgumentException;
1313
use PHPViet\NumberToWords\DictionaryInterface;
14-
use LogicException;
1514

1615
/**
1716
* @method static string toWords($number)
@@ -34,8 +33,6 @@ class N2WFacade extends Facade
3433
*/
3534
protected static function getFacadeAccessor(): Transformer
3635
{
37-
static::checkConfigIsPublished();
38-
3936
$dictionary = static::$dictionary ?? static::getDefaultDictionary();
4037
$dictionary = static::makeDictionary($dictionary);
4138

@@ -66,17 +63,4 @@ protected static function makeDictionary(string $dictionary): DictionaryInterfac
6663

6764
return app()->make($dictionaryClass);
6865
}
69-
70-
/**
71-
* Throw an Exception when the config is not exist
72-
* Please run: php artisan vendor:publish --provider="PHPViet\Laravel\NumberToWords\ServiceProvider" --tag="config"
73-
*
74-
* @throws LogicException
75-
*/
76-
protected static function checkConfigIsPublished()
77-
{
78-
if (!config()->has('n2w')) {
79-
throw new LogicException("The config file is not found. You must publish the config before using it!");
80-
}
81-
}
8266
}

src/ServiceProvider.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
namespace PHPViet\Laravel\NumberToWords;
1010

11-
use Illuminate\Contracts\Support\DeferrableProvider;
1211
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
1312
use PHPViet\NumberToWords\Dictionary;
1413
use PHPViet\NumberToWords\DictionaryInterface;
@@ -18,12 +17,8 @@
1817
* @author Vuong Minh <[email protected]>
1918
* @since 1.0.0
2019
*/
21-
class ServiceProvider extends BaseServiceProvider implements DeferrableProvider
20+
class ServiceProvider extends BaseServiceProvider
2221
{
23-
public $bindings = [
24-
'n2w' => Transformer::class,
25-
];
26-
2722
public $singletons = [
2823
Dictionary::class => Dictionary::class,
2924
DictionaryInterface::class => Dictionary::class,
@@ -41,9 +36,4 @@ public function register(): void
4136
{
4237
$this->mergeConfigFrom(__DIR__.'/../config/n2w.php', 'n2w');
4338
}
44-
45-
public function provides(): array
46-
{
47-
return ['n2w'];
48-
}
4939
}

0 commit comments

Comments
 (0)