How do I use an external library in my project?
Hello everybody, I am using this library for control panel access. https://github.com/chiiya/filament-access-control I like the user policies roles and permissions but I don't know how to extend those same permissions to my resources, example my contact resources I need some advice what I want to do is extend the admin policies to my resources but I have no idea how to do it.
GitHub
GitHub - chiiya/filament-access-control: Admin user, role and permi...
Admin user, role and permission management for Laravel Filament - GitHub - chiiya/filament-access-control: Admin user, role and permission management for Laravel Filament
16 Replies
You just need to build out policies to your models and the resources take into account the models policy
so I have to create something like this right? for each resource I have
Yes
Twilio Blog
What Are Laravel Policies and How to Use Them to Control Access
In this tutorial, you'll learn about how to implement access control in Laravel applications using Laravel Policies
ho thank you very much for the article I am going to read it and keep trying, if I get the solution I will mark it here thanks
hello I still do not get solution, create the policy of ContactoPolicy.php and add these policies similar to the administrators of the chiiya that is what I want I've been trying for 5 hours T_T, I don't understand what else I have to do.
Have you registered the policy? have you tested the policy is being used?
I think that's what I'm missing but I don't know if I'm doing it right.
You assigned it to the resource, you need to assign it to the model
but now I get this error "Target class [Chiiya\FilamentAccessControl\Policies\ContactoPolicy] does not exist." do i have to create a policy like this ? in chiiya's policy
Your naming convention is bad
Change:
PoliciesContactoPolicy
To
ContactoPolicy
Target class [App\Policies\ContactoPolicy] does not exist. xD HAHAHAJ now this comes out, later I pass all the codes in an organized way, to see if you can continue helping me, is that if I need it hehehej thank you very much.
Did you change the class name and the file name?
to ContactoPolicy
yes, I changed it but now I have to go to the university I'm late xD but thank you a greeting I'll explain better later
use Chiiya\FilamentAccessControl\Policies\ContactoPolicy as PoliciesContactoPolicy;
This is the issue, if you have them in \App\Policies which is where it should be...
if that was it, I was doing it backwards, I created the policies in the normal application, and not in the library policies of chiiya, here I leave the solution thank you very much.
Solution
And register policy
I learned a lot thank you very much again 👍