调用未定义的方法 Illuminate\Support\Facades\Gate::define()
Call to undefined method Illuminate\Support\Facades\Gate::define()
我在 Laravel 5.6
中使用 Policy
但出现此错误:
Call to undefined method Illuminate\Support\Facades\Gate::define()
我该如何解决这个问题?
protected $policies = [
'App\Model' => 'App\Policies\ModelPolicy',
];
并在引导中:
public function boot(GateContract $gate)
{
$this->registerPolicies();
$gate->define('isAdmin', function ($user){
return $user->role == 1;
});
}
问题已解决!
public function boot()
{
$this->registerPolicies();
Gate::define('isAdmin', function ($user) {
return $user->role == 1;
});
}
我在 Laravel 5.6
中使用 Policy但出现此错误:
Call to undefined method Illuminate\Support\Facades\Gate::define()
我该如何解决这个问题?
protected $policies = [
'App\Model' => 'App\Policies\ModelPolicy',
];
并在引导中:
public function boot(GateContract $gate)
{
$this->registerPolicies();
$gate->define('isAdmin', function ($user){
return $user->role == 1;
});
}
问题已解决!
public function boot()
{
$this->registerPolicies();
Gate::define('isAdmin', function ($user) {
return $user->role == 1;
});
}