I'm using zizaco/entrust package in my laravel project beside multi Auth package name Hesto/multi-auth
Our project on laravel 5.4,
i get below error when i want to get current logged in users' role and permissions with this method:
Entrust::hasRole('role-name');
OR Auth::user()->hasRole('role-name');
But I can access users' Role with this method for example :
$user = User::find($userid);
dd($user->hasRole('admin')); // Return true
i followed exactly installation instruction but i get below error :
`Non-static method Zizaco\Entrust\Entrust::hasRole() should not be called statically`
How can i solve my problem, Thanks in advance
use
statement. Are you using the class or thefacade
? You want to be using the facade. – sushibrain\Entrust::hasRole();
. Not yet tested, but the solution is that you need to use EntrustFacade mentioned over here : github.com/Zizaco/entrust/blob/master/src/Entrust/… – PaladiNvendor/zizaco/entrust/src/Entrust/Entrust.php
inuser()
method. because im usingHesto/MultiAuth
the previous return couldn't retrive current user ,Then for fix the problem , I changed return$this->app->auth->user();
to returnAuth::guard('user')->user();
but i think still there is a problem with using Entrust Fecade – Hamed Yarandi