From 1df271ce7c0f6c167321b8b8ed51f2650a5dc462 Mon Sep 17 00:00:00 2001 From: Randy Glenn Aguirre Date: Tue, 13 Jun 2017 15:35:08 +0800 Subject: [PATCH] add ability to change menu_ prepend This will allow ``` @include('layouts.site-menu', ['items' => $siteMenu->roots()]) ``` Instead of ``` @include('layouts.site-menu', ['items' => $menu_siteMenu->roots()]) ``` --- config/menu.php | 5 +++++ src/Menu.php | 2 +- src/MenusServiceProvider.php | 11 +++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 config/menu.php diff --git a/config/menu.php b/config/menu.php new file mode 100644 index 0000000..bfaa414 --- /dev/null +++ b/config/menu.php @@ -0,0 +1,5 @@ + 'menu_' +]; \ No newline at end of file diff --git a/src/Menu.php b/src/Menu.php index ef85bb6..df12c9b 100755 --- a/src/Menu.php +++ b/src/Menu.php @@ -66,7 +66,7 @@ public function make($name, $callback) $this->collection->put($name, $menu); - $this->view->share('menu_'.$name, $menu); + $this->view->share(config('menu.prepend','menu_').$name, $menu); return $menu; } diff --git a/src/MenusServiceProvider.php b/src/MenusServiceProvider.php index 5e8db99..0182900 100755 --- a/src/MenusServiceProvider.php +++ b/src/MenusServiceProvider.php @@ -5,6 +5,10 @@ class MenusServiceProvider extends ServiceProvider { + public function boot() + { + $this->publishConfig(); + } /** * Indicates if loading of the provider is deferred. * @@ -47,4 +51,11 @@ protected function registerServices() return new Menu($app['config'], $app['view'], $app['html'], $app['url']); }); } + + protected function publishConfig() + { + $this->publishes([ + __DIR__ . '/../config/menu.php' => config_path('menu.php'), + ], 'caffeinated-menu'); + } }