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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.