I'm using Laravel Entrust Package https://github.com/Zizaco/entrust I want to get all the users with their roles like this
name | role
Ryan | admin
Megan | admin
Table structure
users
id,name,email,password
roles,
id,name
role_user (pivot table)
id,user_id
I tried this but doesn't work
$users = User::with('roles')->where('roles.name','=','admin')->get();
Error
Column not found: 1054 Unknown column 'roles.name' in 'where clause' (SQL: select * from users where roles.name = admin)
I don't want to use neither RAW queries nor this
$users = DB::table('users')->select('users.name as username', 'role.name as role')->with('roles')->join('roles', 'roles.user_id', '=', 'users.id')->where('roles.name', 'admin')->get();
Is there any other way?