dimanche 25 août 2019

Trouble converting an SQL query to Eloquent

Trying to get this query to work in eloquent

A user can be in multiple teams however I want to generate a list of users NOT in a specific team. The following SQL query works if executed directly but would like to make it cleaner by converting it to eloquent

SELECT * FROM users LEFT JOIN team_members ON team_members.member_id = users.id WHERE NOT EXISTS ( SELECT * FROM team_members WHERE team_members.member_id = users.id AND team_members.team_id = $team_id )

This should provide a list of all the users that are not members of team $team_id



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire