Is there a way to listen or hook into when a user switches team?

As the title state, I am wondering if there is a way to execute some code when a user switches team in the panel. I am using the base tenancy that comes with filament.
Solution:
I don't think theres a tenant switcher persay as you can alternate between tenants without issue since we are tenant scoped, but not per tennat limited. So you could have a middleware and a current_tenant_id on the usermodel, if Auth::user()->current_tennat_id !== Filamentphp::getTenant()->id, then change it to the tennat id and log change....
Jump to solution
4 Replies
Solution
toeknee
toeknee4w ago
I don't think theres a tenant switcher persay as you can alternate between tenants without issue since we are tenant scoped, but not per tennat limited. So you could have a middleware and a current_tenant_id on the usermodel, if Auth::user()->current_tennat_id !== Filamentphp::getTenant()->id, then change it to the tennat id and log change.
nerdroid
nerdroidOP3w ago
Oh, that's a good idea. Thanks!
Andrew Wallo
Andrew Wallo3w ago
I think there is also a TenantSet event or something
toeknee
toeknee3w ago
Good spot Andrew

Did you find this page helpful?