Normally I practice with pluck() or lists() to get the list of data.
Nov 7, 2016
9
Level 7
List of Unique Users with Certain Role From Many To Many Relationship
Hi,
I have something like this
users table
---------------
id, <other fields>
roles table
------------------
id, rolename, permission
role_users table
-------------------
roleid, userid
Since I have role and permission on same table, rolename is repeated like this
rolename, permission
admin, siteadmin
admin, useradmin
admin, emailadmin
I have already defined the many to many relationship on both User and Role models.
I need to get a list of unique admins.
What is the most efficient way (less code) to get the result in this case?
Thanks!
Please or to participate in this conversation.