F
Filament6mo ago
Liam

Get tenant on a custom NavigationItem

Hello, I want to add a custom NavigationItem where I need to redirect users to a page in my app outside of Filament, I want to include the tenant id they are currently on with:
NavigationItem::make(__('Abonnementen'))
->url(request()->get('tenant'))
->icon('heroicon-o-credit-card'),
NavigationItem::make(__('Abonnementen'))
->url(request()->get('tenant'))
->icon('heroicon-o-credit-card'),
Filament::getTenant() doesn't work and request()->get('tenant'), doesn't work as well.
Solution:
I guess you need to use a Closure for url then ->url(fn () => ...)
Jump to solution
5 Replies
Dennis Koch
Dennis Koch6mo ago
Filament::getTenant() doesn't work and request()->get('tenant'), doesn't work as well.
I guess this is in a service provider. Tenant info is only available after middleware not on boot. Wrap your nav items in a Closure and you should be good.
Liam
LiamOP6mo ago
@Dennis Koch Thanks for the tip, I tried but unfortunately this doesn't work, I tried to pass a closure in the FilamentServiceProvider
No description
Solution
Dennis Koch
Dennis Koch6mo ago
I guess you need to use a Closure for url then ->url(fn () => ...)
Liam
LiamOP6mo ago
Ah yes it works thanks! my bad haha
Dennis Koch
Dennis Koch6mo ago
All good. Thought your solution works, too. Always forget it's not allowed in that place
Want results from more Discord servers?
Add your server