Reputation: 11
I am beginner in Laravel 5.2 and encountered a problem in my code:
use Illuminate\Auth\Access\Gate;
...
if(Gate::denies('add-article'))
{
return redirect()->back()->with(['message'=>'Unregistered user']);
}
After I got an error:
Non-static method Illuminate\Contracts\Auth\Access\Gate::allows() cannot be called statically
Can somebody help me? Thanks
Upvotes: 1
Views: 535
Reputation: 50481
use Illuminate\Support\Facades\Gate;
// or
use Gate;
You want the Facade, not the underlying class of the Facade. The Facade is a static proxy for an instance of that class.
If you want to use the class, Illuminate\Auth\Access\Gate
, directly you would need an instance of it.
Laravel 5.2 Docs - Authorization - Checking Abilities - via the Gate Facade
Laravel 5.2 Docs - Facades - Class Reference
Upvotes: 3