Support the ongoing development of Laravel.io →
Configuration Database Installation
Last updated 1 year ago.
0

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();

0

Can you please tell how to use the above query in eloquent.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

nijesh17 nijesh17 Joined 18 Jul 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.