Render Hook for inserting livewire custom page into user menu?

I have several panels, and some pages are shared between panels, so I have the panel directories, and then I have a shared directory where all the pages/components live that are used in multiple panels. I want to add a link to a user settings page, and since it will be shared, I want to put it in this shared directory. However, when I create a custom page class like I have with a lot of other use cases, and I use the userMenuItems method on the panel provider, I get a route not defined error and I can't seem to get past it.
->userMenuItems([
MenuItem::make()
->url(fn(): string => Settings::getUrl(['userId' => auth()->id()])),
]);
->userMenuItems([
MenuItem::make()
->url(fn(): string => Settings::getUrl(['userId' => auth()->id()])),
]);
my custom page class:
class Settings extends Page
{

protected static string $view = 'filament.shared.pages.users.settings';
protected static ?string $slug = 'users/{userId}/settings';
protected static bool $shouldRegisterNavigation = false;

public function mount(int $userId)
{
...
class Settings extends Page
{

protected static string $view = 'filament.shared.pages.users.settings';
protected static ?string $slug = 'users/{userId}/settings';
protected static bool $shouldRegisterNavigation = false;

public function mount(int $userId)
{
...
2 questions: first, am I doing something wrong that would allow me to just make this work the way it's laid out above? I don't know why I can't just link to whatever page I want to, whether it's in the panel or not (I'm guessing that's the problem). With the other pages I have that are shared, I have a custom sidebar navigation where I'm creating the NavigationItems manually. This is the first time I've tried to put one of these in the user menu. second, if the above isn't going to work, is there a way to maybe use a renderhook to put a link in my user menu.
I can do this, I think, but just thinking there must be a better way.
FilamentView::registerRenderHook(
PanelsRenderHook::USER_MENU_PROFILE_BEFORE,
fn(): ?String => Blade::render('<div class="fi-dropdown-list p-1">
<a href="http://localhost/users/1/settings"...</a></div>'),
);
FilamentView::registerRenderHook(
PanelsRenderHook::USER_MENU_PROFILE_BEFORE,
fn(): ?String => Blade::render('<div class="fi-dropdown-list p-1">
<a href="http://localhost/users/1/settings"...</a></div>'),
);
3 Replies
Bruno Pereira
Bruno Pereira3mo ago
Does the route appear when you run:
php artisan route:list
php artisan route:list
?
Jon Mason
Jon Mason3mo ago
no it doesn't. I would've thought that adding the $slug attribute would make it create a route. At least I think that's how it works, but regardless, it's not any different than my other classes so I don't understand why it's not creating the route.
Bruno Pereira
Bruno Pereira3mo ago
try to clear laravel + filament caches
php artisan optimize:clear & php artisan filament:optimize-clear
php artisan optimize:clear & php artisan filament:optimize-clear
and see if it shows on route list
Want results from more Discord servers?
Add your server