Hide tenantID in URL

Hello, I am testing multi-tenancy and I was looking if it is possible to hide the tenantID. Since the id is a UUID and visually in the URL it takes up too much. I have looked in the documentation and in #help and I see no reference to this. Is there such a possibility? Thank you very much
Solution:
Did you add a slug column to your team table and set a slug for each team? Obviously you can use whatever column you like, doesn’t need to be called slug. All this does is make the route prettier, so show a short slug instead of an ugly uuid.
Jump to solution
10 Replies
Tim van Heugten
Tim van Heugten4mo ago
The out of the box tenancy requires something in the route. You can replace the id with a slug, see https://filamentphp.com/docs/3.x/panels/tenancy#customizing-the-billing-route-slug. Else you need some custom work to, for example, use a subdomain or something session / db based (take a look at how Jetstream sets a user’s current tenant in the database).
MartinRaiola
MartinRaiola4mo ago
Hello! But with this I can only modify the billing path slug. The base path for a user in the panel with multi-tenancy is of the following format: http://localhost/clients/9b7e80a3-0187-45b2-b941-1f9e0525ebb1 I understand that the tenantId is already being stored in the user session and it would not be necessary to show it in the URL. Because for example when editing the team's profile we are left with a URL of the following format: http://localhost/clients/9b7e80a3-0187-45b2-b941-1f9e0525ebb1/team/9b7e80a3-0187-45b2-b941-1f9e0525ebb1/edit I understand that the second tenantId is necessary to know which team is being worked on. But the first one too?
Tim van Heugten
Tim van Heugten4mo ago
Sorry, copy/pasted the wrong url. Correct one is https://filamentphp.com/docs/3.x/panels/tenancy#configuring-the-slug-attribute - rest of my reply still stands. It’s possible, but up to you to code.
MartinRaiola
MartinRaiola4mo ago
I have tried this you tell me but I can't see how to make it work. In documentation I don't see much more information and looking through the GitHub issues I don't see much else either. Apart from defining it in the panel, what else should I do? I understand that I have to pass the tenantID from the session but I don't see where (or how).
dissto
dissto4mo ago
TenantId from session? Looks like you are on the wrong track. If you could provide some code here, it would be easier to help though.
MartinRaiola
MartinRaiola4mo ago
I have a panel with the following configuration: return $panel ->default() ->id('client') ->path('client') ->login() ->registration() ->passwordReset() ->authGuard('client') ->tenant(Team::class) ->tenantRegistration(RegisterTeam::class) Al tener el multi-tenancy habilitado las urls de los usuarios al acceder son del siguiente formato /client/{team_uuid}
MartinRaiola
MartinRaiola4mo ago
return $panel ->default() ->id('client') ->path('client') ->login() ->registration() ->passwordReset() ->authGuard('client') ->tenant(Team::class, slugAttribute: 'slug') ->tenantRegistration(RegisterTeam::class) but i get this error: Missing required parameter for [Route: filament.client.pages.dashboard] [URI: client/{tenant}] [Missing parameter: tenant].
Solution
Tim van Heugten
Tim van Heugten4mo ago
Did you add a slug column to your team table and set a slug for each team? Obviously you can use whatever column you like, doesn’t need to be called slug. All this does is make the route prettier, so show a short slug instead of an ugly uuid.
MartinRaiola
MartinRaiola4mo ago
Ok! Now I have it working. I didn't understand the slug base as such, I wasn't seeing that it was the field to look for in the DB. Thank you very much for everything!
Want results from more Discord servers?
Add your server
More Posts