Sorry, I don't understand what is your problem. Can you describe more? What exactly doesn't work as you expect?
Trying to understand policies
Hello, trying to use policies properly and I'm following the guidance (https://laravel.com/docs/12.x/authorization) but it's not working for me. I'm new, and I'm guessing I've missed something big.
So I have a File model, and I want users to be able to see only their own files. I have a FilePolicy in app\Policies so it should auto register. I have seen examples using AuthServiceProvider, but that seems to be laravel 11?
I have the Show function in the File controller
public function show(File $file) { Gate::authorize('view', $file);
if(Request()->user()->can("view", $file)){
I know the above code doesn't need authorize and user->can, but neither seem to call the view function on the policy. They are calling something that returns true (debug at shows one gate)
Any pointers?
Please or to participate in this conversation.