简体   繁体   中英

Error in Laravel 5.2

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

Laravel 5.2 Docs - Facades - Class Reference

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM