I want to get all user which don't have admin role, it's a
belongsToMany relation where a user can have many roles. I want to get only the user who is not an admin.
I have tried following but it gives me users nested in each role, I want it a list of users
limit(5) as a collection.
return Role::with('users')->where('name', '!=', 'admin')->get();
here is table structure-
users - id - name - email roles - id - name role_user - user_id - role_id
Any way to do it?