Skip to content

Commit 30e15d5

Browse files
authored
GeoIP :(
1 parent 7a33b2c commit 30e15d5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/VisitsServiceProvider.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,31 @@ public function register()
5252
'visits'
5353
);
5454

55+
5556
// Register GeoIP service provider if not already registered
5657
if (!$this->app->providerIsLoaded(GeoIPServiceProvider::class)) {
5758
$this->app->register(GeoIPServiceProvider::class);
5859
}
59-
60+
6061
// Register GeoIP facade if not already registered
61-
if ($this->app->getAlias('GeoIP') === null) {
62+
$geoipAlias = $this->app->getAlias('GeoIP');
63+
if ($geoipAlias === null) {
6264
$this->app->alias('GeoIP', \Torann\GeoIP\Facades\GeoIP::class);
6365
}
6466

67+
// Make sure GeoIP has a configuration
68+
if (!file_exists(config_path('geoip.php'))) {
69+
$this->publishes([
70+
__DIR__.'/config/geoip.php' => config_path('geoip.php'),
71+
], 'config');
72+
73+
// Force merge the config in the current request
74+
$this->mergeConfigFrom(
75+
__DIR__.'/config/geoip.php',
76+
'geoip'
77+
);
78+
}
79+
6580
$this->app->bind('command.visits:clean', CleanCommand::class);
6681

6782
$this->commands([

0 commit comments

Comments
 (0)