0
我試圖在TeamController應用策略:Laravel政策從來不叫
TeamPolicy是:
public function before(User $user, $ability)
{
if ($user->isSuperAdmin()) {
return true;
}
return null;
}
public function create(User $user, Tournament $tournament)
{
return $user->isOwner($tournament);
}
在我的控制器我這樣調用它:
public function create(Tournament $tournament)
{
$team = new Team;
if (Auth::user()->cannot('create', $team)) {
throw new UnauthorizedException();
}
}
我dd在這兩個函數中,但永遠不會被調用。
任何想法有什麼問題???
我完全忘了! TX! –