From 8a38760cf1e23c2403d16c2fb8c88d2ed6dbf0b6 Mon Sep 17 00:00:00 2001 From: Tacio Brito Date: Thu, 12 Nov 2020 14:03:32 -0300 Subject: [PATCH] Added command to publish the configuration settings --- src/ZoopServiceProvider.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/ZoopServiceProvider.php b/src/ZoopServiceProvider.php index 2fd5a70..e15cd9d 100644 --- a/src/ZoopServiceProvider.php +++ b/src/ZoopServiceProvider.php @@ -24,18 +24,14 @@ class ZoopServiceProvider extends ServiceProvider { * @return void */ public function boot(){ - + $this->registerPublishing(); + $this->mergeConfigFrom(__DIR__.'/resources/config/config.example.php', 'zoopconfig'); } /** * @return void */ public function register(){ - - $configFile = __DIR__.'/resources/config/config.php'; - - $this->mergeConfigFrom($configFile, 'zoopconfig'); - $service = ZoopBase::getSingleton($this->app['config']->get('zoopconfig', [])); $this->app->singleton('ZoopBankAccounts', function () use ($service) { @@ -87,6 +83,21 @@ public function register(){ }); } + /** + * Register the package's publishable resources. + * + * @return void + */ + private function registerPublishing() + { + if ($this->app->runningInConsole()) { + // Lumen lacks a config_path() helper, so we use base_path() + $this->publishes([ + __DIR__.'/resources/config/config.example.php' => base_path('config/zoopconfig.php'), + ], 'config'); + } + } + /** * @return array */