F
Filamentβ€’16mo ago
torriv

Route not defined , custom page

Trying to access a custom page through userMenuItems, but i get the error
Route [filament.admin.pages.settings] not defined.
Route [filament.admin.pages.settings] not defined.
Here is my AdminPanelProvider.php code:
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
->login()
->profile()
->passwordReset()
->colors([
'primary' => Color::Slate,
])
->navigationItems([
..........................................
])
->navigationGroups([
.........................................
])
->userMenuItems([
MenuItem::make()
->label('Settings')
->url(route('filament.admin.pages.settings'))
->icon('heroicon-o-cog-6-tooth'),
])
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
->pages([
//Pages\Dashboard::class,
])
->widgets([
...........................
])
->plugin(FilamentSpatieRolesPermissionsPlugin::make())
->middleware([
...............
])
->authMiddleware([
Authenticate::class,
])
->maxContentWidth('full')
->topNavigation();
}
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
->login()
->profile()
->passwordReset()
->colors([
'primary' => Color::Slate,
])
->navigationItems([
..........................................
])
->navigationGroups([
.........................................
])
->userMenuItems([
MenuItem::make()
->label('Settings')
->url(route('filament.admin.pages.settings'))
->icon('heroicon-o-cog-6-tooth'),
])
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
->pages([
//Pages\Dashboard::class,
])
->widgets([
...........................
])
->plugin(FilamentSpatieRolesPermissionsPlugin::make())
->middleware([
...............
])
->authMiddleware([
Authenticate::class,
])
->maxContentWidth('full')
->topNavigation();
}
It worked on V2. I have cleared all cache. if i remove menu item and just have a link to the page in the regular navigation, it works. Anyone have any suggestions?
Solution:
You are calling this code from a ServiceProvider, so before all of Laravel is ready. You need to use a closure so it's evaluated later. ->url(fn () => route('filament.admin.pages.settings')) Btw. code formatting works with back ticks. Yours are in the wrong direction....
Jump to solution
2 Replies
Solution
Dennis Koch
Dennis Kochβ€’16mo ago
You are calling this code from a ServiceProvider, so before all of Laravel is ready. You need to use a closure so it's evaluated later. ->url(fn () => route('filament.admin.pages.settings')) Btw. code formatting works with back ticks. Yours are in the wrong direction.
torriv
torrivOPβ€’16mo ago
Awesome! thanks, that worked! πŸ™‚
Want results from more Discord servers?
Add your server