Spatie Roles & Permissions with Multi Tenancy
Hi all, this is my first question here.
I am programming a training multi tenancy app wit spatie roles and permissions plugin and multi-tenancy filament option.
Mi issue is about this error. I am completely blocked...
In my AdminPanelProvider I'd set up tenant such this
16 Replies
Kind of this issue here. How can implement Spatie Roles and Permissions with multi tenancy Team model?
Edit: If it helps, this is my flare link > https://flareapp.io/share/87nYz6DP
Flare
The model [Spatie\Permission\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 pro...
Can anyone help with this? 😦
Looks like you will need to extend the
Spatie\Permission\Models\Role
model to implement the team()
relationshipWill take a look and comment @pboivin
Mmmm, the weird thing is that Role is related to User, not tenant
Are you trying to manage the roles in Filament?
Yep, I've installed plugin from fillament website related to plugins and I try to implement with teams. These are my basics
I think that's it. You need the
team()
relationship on the Role
model if you are managing it in a Panel with tenancy.But don't know what kind of relation implement in tenant() function
Do you have any other model and resource in this Panel?
Edit: it's
team()
not tenant()
, my badLet me explain what I did and I have.
First of all installed filament and set up this plugin > https://filamentphp.com/plugins/tharinda-rodrigo-spatie-roles-permissions. All good with this
Create an user, create a SuperAdmin Role and then asociate user to role
Next steps, implement multi tenancy
Ok, I understand. So if this is an issue with the plugin specifically, you should ask in the channel (if there is one) or Github. Not all plugin authors are on Discord.
oh, sounds good
But just a note as to what I'm saying above: All your resources that are in a Filament Panel with tenancy need a relationship to the tenant. Here's a quick example:
Check with the plugin author to see if this relationship is already setup for you or not.
humm, thank you
Now I can view Role and Permission menu but now cannot associate role with user because of team_id error. Gonna investigate and in case create new help ticket. Thank you so much @pboivin
ownershipRelationship is not team! owner is users