F
Filament5mo ago
SirFat

Spatie Team ID v Filament Tenancy timing

Hi, I'm trying to get Spatie permissions with Teams up and going, and I'm noticing an inconsistency where sometimes the 'tenant' will be passed through and sometimes I won't. I have middleware setting the teamID per documentation and other feedback I've seen. I've attempted to reimplement middleware priority, but to no effect. Using XDebug, I can see that when the middleware is called, the tenant has not yet been set; therefore, when Spatie deals with it:
select `roles`.*, `model_has_roles`.`model_id` as `pivot_model_id`, `model_has_roles`.`role_id` as `pivot_role_id`, `model_has_roles`.`model_type` as `pivot_model_type`, `model_has_roles`.`company_id` as `pivot_company_id` from `roles` inner join `model_has_roles` on `roles`.`id` = `model_has_roles`.`role_id` where `model_has_roles`.`company_id` is null and (`roles`.`company_id` is null or `roles`.`company_id` is null) and `model_has_roles`.`model_id` in (1) and `model_has_roles`.`model_type` = 'App\\Models\\User'
select `roles`.*, `model_has_roles`.`model_id` as `pivot_model_id`, `model_has_roles`.`role_id` as `pivot_role_id`, `model_has_roles`.`model_type` as `pivot_model_type`, `model_has_roles`.`company_id` as `pivot_company_id` from `roles` inner join `model_has_roles` on `roles`.`id` = `model_has_roles`.`role_id` where `model_has_roles`.`company_id` is null and (`roles`.`company_id` is null or `roles`.`company_id` is null) and `model_has_roles`.`model_id` in (1) and `model_has_roles`.`model_type` = 'App\\Models\\User'
Multiple company_id is null. Happy to raise this to Spatie as well, but wondering if anyone had some insight? Thanks!
1 Reply
Dennis Koch
Dennis Koch5mo ago
Where is this query coming from? From a middleware itself? Does that middleware run after Tenant Identification?

Did you find this page helpful?