F
Filament2mo ago
Fravi

Permission on Relation Manager

Hello I'm currently using a Filament shield plugin I'm using relation manager on 1 resource i want to include the relation manager to have roles and permission. Can anyone help me please?
18 Replies
christmex
christmex2mo ago
sorry but can u please make more explanation on wht are u want to achieve
Fravi
FraviOP2mo ago
I need to assign roles and permission to the Relation Manager
christmex
christmex2mo ago
you can create policy based on the relation manager model
Fravi
FraviOP2mo ago
Is there documentation on how to implement it? sorry Im new to filament shield
toeknee
toeknee2mo ago
It's all part of the model, so if they have permission to create or edit a resource model item, then they can edit and create in the relationship
Fravi
FraviOP2mo ago
Yes i have a resource with a relationship manager i just want to set a role that can only view the relation Manager in that specific resource and disable the create and edit in the relation manager
toeknee
toeknee2mo ago
But you still want them to be able to edit/create in the resource the relation manager is tied too?
Fravi
FraviOP2mo ago
If a user role is assigned they can edit so they can view the relation manager but I don't want the user role to create and edit data in the relation manager field
toeknee
toeknee2mo ago
Do you understand that they can only do that, if they can edit/delete on the model/resource that the relationship is tied too? If they can create and eidt users and you can edit roles, and your relationship is a users relationship, they will be able to create and edit users within the relationship manager If they cannot create/edit users then they cannot do it in the users relationship either.
Fravi
FraviOP2mo ago
just like here only super_admin/admin can only create schedule and lets say instructor/student can only view it, they cannot create/edit and delete.
No description
toeknee
toeknee2mo ago
so providing you have the permissions set correctly then they will only be able to view the relationship schedule too.
Fravi
FraviOP2mo ago
yes exactly
toeknee
toeknee2mo ago
So theres nothing to do specifically for relationships here. Just set the permissions and ensure you have the policies created.
Fravi
FraviOP2mo ago
i created policy for schedule which i used for relation schedule and then i cant make it appear in the filament shield
toeknee
toeknee2mo ago
You need to sync the permissions with shield
Fravi
FraviOP2mo ago
I want to make sure it's clear. I created a schedule policy based on the schedule model, which I used on the relation manager. However, this relation manager doesn't have a resource just inside a parent resource, and I can't make it appear in the shield to assign roles and permissions.
toeknee
toeknee2mo ago
Providing the model protected with the policy then it will inherit the permissions.
Faycool
Faycool2mo ago
I encountered the same issue. Since Shield will only resolve models set as a Resource, I worked around the problem by defining my relation managers' models as resources and then disabling them in their resource classes by adding:
public static function canAccess(): bool { return false; }
Want results from more Discord servers?
Add your server