I created a policy named ProjectPolicy
with one function:
public function update(User $user, Project $project)
{
return $project->owner_id == $user->id;
}
I registered my policy in my AuthServiceProvider
as:
protected $policies = [
'App\Project' => 'App\Policies\ProjectPolicy'
]
Also in the AuthServiceProvider
, I have this:
public function boot(Gate $gate)
{
$this->registerPolicies();
$gate->before(function ($user) {
return $user->isAdmin();
});
}
This is supposed to not apply the policy if the user is admin. But when I do this, it completely takes away the access for non-admin users. Why?