Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dannydg's avatar

how to list the users with roles id

I want to list the users with roles through role id how we can do that my approach to do is

User::with("roles")->where("role_id", 1); 

but its gives error of column not found role_id

0 likes
2 replies
deansatch's avatar

Does your users table have a role_id column? If not that won't work. What is your relationship setup and table structure?

Snapey's avatar

how are users and roles related?

Please or to participate in this conversation.