-
I can't access any This doesn't work: public function share(Request $request): array
{
dump($request->routeIs('home')); // false on 'home' route
dump($request->route()); // null
return array_merge(parent::share($request), [
'navigation' => [
['name' => 'Dashboard', 'href' => route('home'), 'current' => $request->routeIs('home')],
],
]);
} This dumps the current route, though: public function version(Request $request): ?string
{
dump($request->routeIs('home')); // true on 'home' route
dump($request->route()); // correct instance of Illuminate\Routing\Route
if (file_exists($manifest = public_path('build/manifest.json'))) {
return md5_file($manifest);
}
return null;
} |
Beta Was this translation helpful? Give feedback.
Answered by
benjivm
Apr 13, 2023
Replies: 1 comment
-
This appears to be an issue with global middleware? I created a custom middleware and registered in the 'web' middleware group of the HTTP Kernel and it works now:
class ShareInertiaData
{
public function handle(Request $request, Closure $next): Response
{
Inertia::share([
'navigation' => [
['name' => 'Dashboard', 'href' => route('home'), 'current' => $request->routeIs('home')],
],
]);
return $next($request);
}
} HTTP protected $middlewareGroups = [
'web' => [
// ...
\App\Http\Middleware\ShareInertiaData::class,
],
'api' => [
// ...
],
]; |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
benjivm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This appears to be an issue with global middleware? I created a custom middleware and registered in the 'web' middleware group of the HTTP Kernel and it works now:
ShareInertiaData.php
middleware:HTTP
Kernel.php
: