So I need help learning how to create policies to do authorization. I understands Gates pretty well, and they work for me, but when I create a policy, it doesn't work.
Here is the code that I'm using. I think the issue that Im having is trying to find out where do you put the check for authorization for a given model function?
public function update(User $user, Message $message)
{
return true;
}
Here I'm just toggling the test to either true or false, just to see how things work. But when I do this in the Message controller:
if ($user->can('update', $message)) {
return 'You can update this post';
}
It doesn't work. I also ran across another approach to checking authorization in the controller using $this->authorize('update', $message); But that didn't work either.
Thank you.
AuthServiceProvider
? – Doom5