Zizaco / entrust

Role-based Permissions for Laravel 5
MIT License
6.05k stars 1.29k forks source link

Not able to verify $user->hasRole() condition in laravel controller #939

Open bhattaxay opened 5 years ago

bhattaxay commented 5 years ago

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.