0
votes

I am using Policy in Laravel 5.6

But getting this Error:

Call to undefined method Illuminate\Support\Facades\Gate::define()

How can I resolve this problem?

protected $policies = [
        'App\Model' => 'App\Policies\ModelPolicy',
    ];

and in boot:

public function boot(GateContract $gate)
{
        $this->registerPolicies();

        $gate->define('isAdmin', function ($user){
            return $user->role == 1;
        });
}
1
What happens if you replace $gate->define with Gate::define?Felippe Duarte

1 Answers

3
votes

Problem Solved!

public function boot()
{
    $this->registerPolicies();

    Gate::define('isAdmin', function ($user) {
        return $user->role == 1;
    });
}