How do you get the current tenant id?
I'd like to get the current team id (team = my tenant) when in a controller, e.g.
But it's returning "null" (also returns null if I just do
Filament::getTenant();
Solution:Jump to solution
Had to go digging in the filament vendor package... Basically, you add an event listener to the setTenant function.
php artisan make:listener UpdateLatestTeamId --event=TenantSet
Then in your new file (e.g. app/Listeners/UpdateLatestTeamId.php
) you could put...2 Replies
The docs talk about getting the latest tenant: https://filamentphp.com/docs/3.x/panels/tenancy#setting-the-default-tenant
I've added a migration to add the latest_tenant_id column, but how do we set this value?
Solution
Had to go digging in the filament vendor package... Basically, you add an event listener to the setTenant function.
php artisan make:listener UpdateLatestTeamId --event=TenantSet
Then in your new file (e.g. app/Listeners/UpdateLatestTeamId.php
) you could put
And then you need to register your new listener in app/Providers/EventServiceProvider.php
like so