Not able to verify $user->hasRole() condition in laravel controller
bhattaxay opened this issue · comments
Akshay commented
Hello there,
I am using this plugin in laravel, when i put this condition in laravel controller
$user= Auth::user();
if(Auth::user()->hasRole(['owner', 'admin']){
//my code goes here
}else{
return response()->json(['status'=>0,'data'=>'Access Denied'],$this-> accessForbidden);
}
It returns me role instead of return true or false.
Also i want to know one more thing that how exactely Auth::user()->hasRole() is working?
Is it compare user role with existing role in my database? If yes than how?
And let me know how to do this stuff in laravel controller? I know the thing but need to confirm.