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
sorry but can u please make more explanation on wht are u want to achieve
I need to assign roles and permission to the Relation Manager
you can create policy based on the relation manager model
Is there documentation on how to implement it? sorry Im new to filament shield
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
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
But you still want them to be able to edit/create in the resource the relation manager is tied too?
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
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.
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.
so providing you have the permissions set correctly then they will only be able to view the relationship schedule too.
yes exactly
So theres nothing to do specifically for relationships here. Just set the permissions and ensure you have the policies created.
i created policy for schedule which i used for relation schedule and then i cant make it appear in the filament shield
You need to sync the permissions with shield
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.
Providing the model protected with the policy then it will inherit the permissions.
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; }