Panel Issues

I am running into some issues working with a panel. The help functions route() and auth() are giving me errors. The route() helper states the named route doesn't exist when it does. And the auth() helper is stating a user provider isn't defined. Are these helper methods not useable within the Filament environment?
return $panel
...
->navigationItems([
NavigationItem::make('Home')
->icon('heroicon-o-home')
->url(route('home')
->sort(1),
NavigationItem::make('Admin Panel')
->url('/admin')
->sort(2)
->visible(auth()->user()->hasRoles('Super Admin')),
])
...
return $panel
...
->navigationItems([
NavigationItem::make('Home')
->icon('heroicon-o-home')
->url(route('home')
->sort(1),
NavigationItem::make('Admin Panel')
->url('/admin')
->sort(2)
->visible(auth()->user()->hasRoles('Super Admin')),
])
...
Solution:
This is in a ServiceProvider. Routes aren't booted yet. Use a Closure for lazy evaluation url(fn () => route('home'))
Jump to solution
2 Replies
Solution
Dennis Koch
Dennis Koch13mo ago
This is in a ServiceProvider. Routes aren't booted yet. Use a Closure for lazy evaluation url(fn () => route('home'))
Horizons
HorizonsOP13mo ago
Thank you @Dennis Koch. That solved both problems.
Want results from more Discord servers?
Add your server