Skip to content

Commit 1df271c

Browse files
committed
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()]) ```
1 parent 5189c75 commit 1df271c

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

config/menu.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
return [
4+
'prepend' => 'menu_'
5+
];

src/Menu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function make($name, $callback)
6666

6767
$this->collection->put($name, $menu);
6868

69-
$this->view->share('menu_'.$name, $menu);
69+
$this->view->share(config('menu.prepend','menu_').$name, $menu);
7070

7171
return $menu;
7272
}

src/MenusServiceProvider.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
class MenusServiceProvider extends ServiceProvider {
77

8+
public function boot()
9+
{
10+
$this->publishConfig();
11+
}
812
/**
913
* Indicates if loading of the provider is deferred.
1014
*
@@ -47,4 +51,11 @@ protected function registerServices()
4751
return new Menu($app['config'], $app['view'], $app['html'], $app['url']);
4852
});
4953
}
54+
55+
protected function publishConfig()
56+
{
57+
$this->publishes([
58+
__DIR__ . '/../config/menu.php' => config_path('menu.php'),
59+
], 'caffeinated-menu');
60+
}
5061
}

0 commit comments

Comments
 (0)