Skip to content

Commit

Permalink
adding config to make configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
serkanerip committed Mar 10, 2021
1 parent 1024c2b commit 4183e56
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Country.php
Expand Up @@ -62,8 +62,10 @@ protected function data($locale)
{
if (! isset($this->data[$locale])) {
$path = base_path('vendor/umpirsky/country-list/data/'.$locale.'/country.php');
$customCountries = config("laravel-int.countries.$locale", []);

$this->data[$locale] = is_file($path) ? require $path : [];
$this->data[$locale] = array_merge($this->data[$locale], $customCountries);
}

return $this->data[$locale];
Expand Down
15 changes: 15 additions & 0 deletions src/IntlServiceProvider.php
Expand Up @@ -20,6 +20,7 @@ public function register()
$this->registerLanguage();
$this->registerNumber();
$this->registerDate();
$this->registerConfig();
}

/**
Expand All @@ -36,6 +37,20 @@ public function boot()
$this->setLocale();
}

/**
* Register config.
*/
protected function registerConfig()
{
$this->publishes([
__DIR__.'/config/config.php' => config_path('laravel-int.php'),
], 'config');
$this->mergeConfigFrom(
__DIR__.'/config/config.php',
'laravel-int'
);
}

/**
* Register the country repository.
*
Expand Down
12 changes: 12 additions & 0 deletions src/config/config.php
@@ -0,0 +1,12 @@
<?php

return [
'countries' => [
'en' => [
'XK' => 'Kosovo'
],
'tr' => [
'XK' => 'Kosova'
]
]
];

0 comments on commit 4183e56

Please sign in to comment.