2016-07-25 107 views
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在这两个函数中,但永远不会被调用。

任何想法有什么问题???

回答