|
2 | 2 |
|
3 | 3 | namespace PulkitJalan\GeoIP\Laravel; |
4 | 4 |
|
| 5 | +use PulkitJalan\GeoIP\Laravel\Console\UpdateCommand; |
5 | 6 | use Illuminate\Support\ServiceProvider; |
| 7 | +use PulkitJalan\GeoIP\GeoIP; |
6 | 8 |
|
7 | 9 | class GeoIPServiceProvider extends ServiceProvider |
8 | 10 | { |
@@ -32,18 +34,44 @@ public function register() |
32 | 34 | { |
33 | 35 | $this->app->config->package('pulkitjalan/geoip', realpath(__DIR__.'/config'), 'geoip'); |
34 | 36 |
|
| 37 | + $this->registerGeoIP(); |
| 38 | + |
| 39 | + $this->registerUpdateCommand(); |
| 40 | + } |
| 41 | + |
| 42 | + /** |
| 43 | + * Register the main geoip wrapper |
| 44 | + * |
| 45 | + * @return void |
| 46 | + */ |
| 47 | + protected function registerGeoIP() |
| 48 | + { |
35 | 49 | $this->app['geoip'] = $this->app->share(function ($app) { |
36 | 50 | return new GeoIP($app->config->get('geoip::config')); |
37 | 51 | }); |
38 | 52 | } |
39 | 53 |
|
| 54 | + /** |
| 55 | + * Register the geoip update console command. |
| 56 | + * |
| 57 | + * @return void |
| 58 | + */ |
| 59 | + protected function registerUpdateCommand() |
| 60 | + { |
| 61 | + $this->app['command.geoip.update'] = $this->app->share(function ($app) { |
| 62 | + return new UpdateCommand($app->config->get('geoip::config')); |
| 63 | + }); |
| 64 | + |
| 65 | + $this->commands(array('command.geoip.update')); |
| 66 | + } |
| 67 | + |
40 | 68 | /** |
41 | 69 | * Get the services provided by the provider. |
42 | 70 | * |
43 | 71 | * @return string[] |
44 | 72 | */ |
45 | 73 | public function provides() |
46 | 74 | { |
47 | | - return ['geoip', 'PulkitJalan\GeoIP\GeoIP']; |
| 75 | + return ['geoip', 'command.geoip.update', 'PulkitJalan\GeoIP\GeoIP']; |
48 | 76 | } |
49 | 77 | } |
0 commit comments