0
我试图在Laravel 5.4中创建一个acl。在5.2它使用这样的工作,但5.4是不喜欢这个了,它给此错误消息:AuthServiceProvider.php中的ErrorException Laravel 5.4中的未定义变量
ErrorException在AuthServiceProvider.php未定义的变量:门
任何人都可以解释为什么它不工作,以及如何要解决这个问题? 这里是我的代码:
public function boot()
{
$this->registerPolicies();
$gate->define('auth', function($user, $role=NULL){
if($role === NULL){
$actions = Route::current()->getAction();
if(! isset($actions['role']))
return false;
$role = $actions['role'];
}
$objRole = new Role();
$roles = $objRole->roles($user->id);
if(in_array($role, $roles))
return true;
return false;
});
}
'$ gate'不被任何定义?很高兴看到它的定义。 –
它在这里被定义,还是我做错了? $ gate-> define('auth',function($ user,$ role = NULL) – Geisiane