Multi-tenancy with Shield

Does my roles table have to have a team_id?
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'roles.team_id' in 'where clause' I would think roles would be the same regardless of the team, so I think I probably have something configured incorrectly. If I take the team relationship off my role model I get:
The model [App\Models\Role] does not have a relationship named [team]. You can change the relationship being used by passing it to the [ownershipRelationship] argument of the [tenant()] method in configuration. You can change the relationship being used per-resource by setting it as the [$tenantOwnershipRelationshipName] static property on the [BezhanSalleh\FilamentShield\Resources\RoleResource] resource class.
The model [App\Models\Role] does not have a relationship named [team]. You can change the relationship being used by passing it to the [ownershipRelationship] argument of the [tenant()] method in configuration. You can change the relationship being used per-resource by setting it as the [$tenantOwnershipRelationshipName] static property on the [BezhanSalleh\FilamentShield\Resources\RoleResource] resource class.
So it seems that every single table has to have a team_id for multi-tenancy?
Solution:
protected static bool $isScopedToTenant = false;
Jump to solution
4 Replies
Patrick Boivin
Patrick Boivin14mo ago
Yes, I think you need a relationship to the tenant for every resource in a Panel with multi-tenancy. You can skip the tenant relationship in other contexts like relation manager, select field, etc.
Jon Mason
Jon MasonOP14mo ago
hmmm...ok, so that means I have to duplicate roles across the tenants if I want to have the same roles? So "user" role for tenant 1 and "user" role for tenant 2, etc?
Patrick Boivin
Patrick Boivin14mo ago
I'm not sure, I feel like there's a way... I think you could manage the users and roles in a separate panel without tenancy. Or override part of the Role resource to ignore the tenancy. I know others have discussed it on Discord.
Solution
edson36
edson3612mo ago
protected static bool $isScopedToTenant = false;
Want results from more Discord servers?
Add your server