Skip to content
Advertisement

join a single table twice in join query

I have 3 tables users and meeting table and user_role. In user table I have user_name and user_role fields and in meeting table I have the column meeting_id assigned_username and created_by_user_name fields and In user_roles table have id and role .

JavaScript

I want to get the assigned_user_name’s user_role and created_by_user_name’s user_role in single query. I have tried as

JavaScript

but getting

Call to a member function whereIn() on array

how to get role of assigned_user_name and created_by_user_name.

Advertisement

Answer

You must use get() before you can use toArray() if you want to get the values as an array.

Also, there may be a typo for your whereIn, should it be carole.id?

Here is what the query could look like in SQL:

JavaScript

And in Laravel query builder:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement