From 6be5f06dbf459dcd24b6aafd7fca18f2075f6949 Mon Sep 17 00:00:00 2001 From: Elf Sundae Date: Fri, 13 Oct 2017 19:49:43 +0800 Subject: [PATCH] Fix merging config --- src/DataTablesServiceProvider.php | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/DataTablesServiceProvider.php b/src/DataTablesServiceProvider.php index 98651d83..84b594a9 100644 --- a/src/DataTablesServiceProvider.php +++ b/src/DataTablesServiceProvider.php @@ -15,20 +15,6 @@ class DataTablesServiceProvider extends ServiceProvider */ protected $defer = false; - /** - * Bootstrap the application events. - * - * @return void - */ - public function boot() - { - $this->mergeConfigFrom(__DIR__ . '/config/datatables.php', 'datatables'); - - $this->publishes([ - __DIR__ . '/config/datatables.php' => config_path('datatables.php'), - ], 'datatables'); - } - /** * Register the service provider. * @@ -40,6 +26,8 @@ public function register() require_once 'lumen.php'; } + $this->setupAssets(); + $this->app->alias('datatables', DataTables::class); $this->app->singleton('datatables', function () { return new DataTables; @@ -52,6 +40,20 @@ public function register() $this->app->singleton('datatables.config', Config::class); } + /** + * Setup package assets. + * + * @return void + */ + protected function setupAssets() + { + $this->mergeConfigFrom($config = __DIR__ . '/config/datatables.php', 'datatables'); + + if ($this->app->runningInConsole()) { + $this->publishes([$config => config_path('datatables.php')], 'datatables'); + } + } + /** * Check if app uses Lumen. *