Closed thewebartisan7 closed 4 years ago
I think that I found in issue a solution, here https://github.com/spatie/laravel-menu/issues/53
There is other better way or this is still the only one?
Thanks!
I was able to make this work, but without macro. I suppose there is no way with macro.
Seem the only way it's by using a singleton instance.
In my service provider I add:
// Service Provider
public function register()
{
// User Requests
$this->app->singleton('mymenu', function() {
return Menu::new()
->link('/', 'Home')
->link('/about', 'About');
->setActiveFromRequest();
});
}
// Somewhere else in application
app('mymenu')->link('/contact', 'Contact');
// Then in view the only thing that I can to render menu seem using alias, since there is not macro.
echo app('menu.sidebar');
Please let me know if there is better way to handle this
Thanks
That's a good way to handle it 👍
I have a question how to solve something with this package, I hope someone can let me know.
I would like to know how to allow to add more links by different package on the same menu.
I don't want to use database to store the menu links, but PHP with macro.
I have a menu defined in a package, then I would like to allow other package to extend my menu by adding more links.
Thanks