I'm trying to apply a policy on a TeamController:
TeamPolicy is :
public function before(User $user, $ability)
{
if ($user->isSuperAdmin()) {
return true;
}
return null;
}
public function create(User $user, Tournament $tournament)
{
return $user->isOwner($tournament);
}
In my controller I call it this way:
public function create(Tournament $tournament)
{
$team = new Team;
if (Auth::user()->cannot('create', $team)) {
throw new UnauthorizedException();
}
}
I dd inside both functions, but never get called.
Any idea what's wrong???