Don't know if you're using eloquent or query builder, but the whereIn()
/whereNotIn()
accepts a Closure as 2nd argument. Something like this:
DB::table('users')->select('username', 'firstname')->whereNotIn('id', function($query) { $query->table('course_enroles')->select('user_id')->where('course_id', '=', 1); })->get();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community