Where should I put the app(Navigation::class)... #11
-
Hi A very simple Tutorial would be very nice. Mathieu |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Typically, you would add this in a service provider. |
Beta Was this translation helpful? Give feedback.
-
You need to build your navigation inside of public function boot() {
$this->app->booted(function () {
app(Navigation::class)->add(...);
});
} Alternatively, you could build your navigation in a middleware. This was my approach since I am using Inertia and used the public function share(Request $request)
{
return array_merge(parent::share($request), [
'navigation' => $this->buildNavigation()->tree()
]
}
protected function buildNavigation()
{
return app(Navigation::class)->add(...);
} |
Beta Was this translation helpful? Give feedback.
-
Hi @jameswagoner, any invocation of I've so far failed to get this package to work as a Service Provider, and given the problems other people have had, it seems to me the README would benefit from a quick edit. |
Beta Was this translation helpful? Give feedback.
-
Yeah, I did experience that as well. I felt it was kinda silly do have the navigation built in essentially a callback of callback in a service provider. I was in L8.x at that time though. I have a recent L10 and Inertia project started and getting to the same point with needing some navigation. I can follow up if I take a different approach. |
Beta Was this translation helpful? Give feedback.
Typically, you would add this in a service provider.