I want to retrieve the users (from users table) that aren't in any group yet (group_user table) and are etudiant type (users.type="etudiant")
I tried this in my function but it give me repeted users from both tables
$Othersetudiants=DB::Table('users')
->join('group_user', 'users.id', '!=', 'group_user.user_id')
->select('users.*')
->where([['users.type','=','etudiant'],
['users.id', '!=', 'group_user.user_id']
])
->get();
Here is my data and tables all foreign keys are set in migrations..
Group:
group_user:
user: