@@ -21,22 +21,40 @@ class GeocoderService extends ServiceProvider
2121
2222 public function boot ()
2323 {
24- $ configPath = __DIR__ . '/../../config/geocoder.php ' ;
25- $ this ->publishes ([$ configPath => config_path ('geocoder.php ' )], 'config ' );
26- $ this ->mergeConfigFrom ($ configPath , 'geocoder ' );
27- $ this ->app ->singleton ('geocoder ' , function () {
24+ $ configPath = __DIR__ . "/../../config/geocoder.php " ;
25+ $ this ->publishes (
26+ [$ configPath => $ this ->configPath ("geocoder.php " )],
27+ "config "
28+ );
29+ $ this ->mergeConfigFrom ($ configPath , "geocoder " );
30+ $ this ->app ->singleton ("geocoder " , function () {
2831 return (new ProviderAndDumperAggregator )
29- ->registerProvidersFromConfig (collect (config (' geocoder.providers ' )));
32+ ->registerProvidersFromConfig (collect (config (" geocoder.providers " )));
3033 });
3134 }
3235
3336 public function register ()
3437 {
35- $ this ->app ->alias (' Geocoder ' , Geocoder::class);
38+ $ this ->app ->alias (" Geocoder " , Geocoder::class);
3639 }
3740
3841 public function provides () : array
3942 {
40- return ['geocoder ' ];
43+ return ["geocoder " ];
44+ }
45+
46+ protected function configPath (string $ path = "" ) : string
47+ {
48+ if (function_exists ("config_path " )) {
49+ return config_path ($ path );
50+ }
51+
52+ $ pathParts = [
53+ app ()->basePath (),
54+ "config " ,
55+ trim ($ path , "/ " ),
56+ ];
57+
58+ return implode ("/ " , $ pathParts );
4159 }
4260}
0 commit comments