Tenant Settings page under provider

I'm unaware if this is a coding issue on my end or a bug. I've created a custom page called Settings which have the name filament.app.pages.settings. When I dump this in a test route outside Filament I get this "http://localhost/app/dwa/settings" // routes/web.php:29 When I try this:
->tenantMenuItems([
MenuItem::make()
->label('Settings')
->url(route('filament.app.pages.settings'))
->icon('heroicon-m-cog-8-tooth'),
// ...
])
->tenantMenuItems([
MenuItem::make()
->label('Settings')
->url(route('filament.app.pages.settings'))
->icon('heroicon-m-cog-8-tooth'),
// ...
])
under my provider it says the route name does not exist?
Solution:
@anitexs You have to do a closure inside it for it to work. The docs are wrong on this so I guess open an issue or I can. But do this instead. For a page inside a panel that DOESN'T have tenancy you can do one of these:...
Jump to solution
34 Replies
N. Jacobsen
N. JacobsenOP16mo ago
Brian Kidd
Brian Kidd16mo ago
Run php artisan route:list to see what the route is named
N. Jacobsen
N. JacobsenOP16mo ago
That's where I got the name from 🙂
N. Jacobsen
N. JacobsenOP16mo ago
awcodes
awcodes16mo ago
What if you did ->url(SettingsPage::getUrl()). Might not be the correct text but it’s typically better to call the url off the class than to use the route helper in a filament context.
N. Jacobsen
N. JacobsenOP16mo ago
N. Jacobsen
N. JacobsenOP16mo ago
Still the same
N. Jacobsen
N. JacobsenOP16mo ago
And I am reffering to the correct settings page
awcodes
awcodes16mo ago
Do you mind sharing the Settings class you are using. Maybe even a dumb question but is this you’re only panel and if so does it have ->default() on it? Might even need getUrl(panel: ‘panel-id’) Default should take care of that though.
N. Jacobsen
N. JacobsenOP16mo ago
I have the admin panel which is not a tenant based. Then I have the App Panel which is Tenant based. I have two tenants in my test enviroment right now.
awcodes
awcodes16mo ago
Two panels you mean?
N. Jacobsen
N. JacobsenOP16mo ago
Yes.
awcodes
awcodes16mo ago
At least one of them needs default() otherwise it will break things.
N. Jacobsen
N. JacobsenOP16mo ago
I've placed the default on the App now Still same issue
N. Jacobsen
N. JacobsenOP16mo ago
awcodes
awcodes16mo ago
Try passing the panel to the getUrl function.
N. Jacobsen
N. JacobsenOP16mo ago
N. Jacobsen
N. JacobsenOP16mo ago
Still the same issue
awcodes
awcodes16mo ago
Sorry not sure then. Source diving the code looks like that should work.
N. Jacobsen
N. JacobsenOP16mo ago
That what I thought too
awcodes
awcodes16mo ago
Could be a bug. Just not sure. I don’t have a lot of need for tenancy so I’m not overly experienced with it in v3.
N. Jacobsen
N. JacobsenOP16mo ago
When I go to my custom route called /test It pastes the correct path
N. Jacobsen
N. JacobsenOP16mo ago
It's like the route name is not yet loaded
awcodes
awcodes16mo ago
If I have time tomorrow I can play around with it some. Hope someone else can help out though.
N. Jacobsen
N. JacobsenOP16mo ago
If you get it to work, please let me know 🙂
awcodes
awcodes16mo ago
Will definitely do. I want to understand the tenancy stuff more. Just hard to do without a practical need. But will let you know for sure.
N. Jacobsen
N. JacobsenOP16mo ago
You found something? 🙂
josef
josef16mo ago
I notice that it's Settings::class and not Pages\Settings:class, is it in the correct location and namespace?
Solution
Andrew Wallo
Andrew Wallo16mo ago
@anitexs You have to do a closure inside it for it to work. The docs are wrong on this so I guess open an issue or I can. But do this instead. For a page inside a panel that DOESN'T have tenancy you can do one of these:
MenuItem::make()
->label('Settings')
->url(fn() => url(Settings::getUrl()))
->icon('heroicon-m-cog-8-tooth'),
MenuItem::make()
->label('Settings')
->url(fn() => url(Settings::getUrl()))
->icon('heroicon-m-cog-8-tooth'),
MenuItem::make()
->label('Settings')
->url(fn() => route('filament.app.pages.settings'))
->icon('heroicon-m-cog-8-tooth'),
MenuItem::make()
->label('Settings')
->url(fn() => route('filament.app.pages.settings'))
->icon('heroicon-m-cog-8-tooth'),
For a page inside a panel that DOES have tenancy you do this:
MenuItem::make()
->label('Settings')
->url(fn() => url(Settings::getUrl()))
->icon('heroicon-m-cog-8-tooth'),
MenuItem::make()
->label('Settings')
->url(fn() => url(Settings::getUrl()))
->icon('heroicon-m-cog-8-tooth'),
Andrew Wallo
Andrew Wallo16mo ago
You can also pass in the tenant parameter inside the getUrl() method but it isn't required and should work either way. I would guess the issue arises because url(Page::getUrl()) expression is evaluated immediately when not inside a closure. If the route associated with Page::getUrl() hasn't been defined at that point, the error occurs.
N. Jacobsen
N. JacobsenOP16mo ago
I tried all of them haha, but yes Settings::class was correct since I included it in the use at the top. If you could do it that would be wonderful 🙂
Andrew Wallo
Andrew Wallo16mo ago
Did what I showed you work?
N. Jacobsen
N. JacobsenOP16mo ago
I've not tested, I will do in a sec 🙂 It works 😄 Thanks 🙂 This one:
MenuItem::make()
->label('Settings')
->url(fn() => url(Settings::getUrl()))
->icon('heroicon-m-cog-8-tooth'),
MenuItem::make()
->label('Settings')
->url(fn() => url(Settings::getUrl()))
->icon('heroicon-m-cog-8-tooth'),
Andrew Wallo
Andrew Wallo16mo ago
Good. Your welcome
Want results from more Discord servers?
Add your server