Policy method not working as expected

Posted 4 months ago by timgavin

I'm working on a policy that will only allow users with the role of creator to create posts. However, this isn't working as expected, as any user with the role of creator is being denied.

What am I doing wrong?

PostPolicy.php

public function create(User $user)
{
    if ($user->role == 'creator') {
        return true;
    }
}

PostController.php

public function create()
{        
    $this->authorize('create');
    
    return view('posts.create');
}

Please sign in or create an account to participate in this conversation.