I'm trying to search all the users registered for a particular course using the following query using the laravel.
$users = DB::table('users')
->leftJoin('registrationrequests', 'users.id', '=', 'registrationrequests.user_id')
->where('firstname', 'LIKE', "%$search%")
->orWhere('lastname', 'LIKE', "%$search%")
->orWhere('username', 'LIKE', "%$search%")
->where('registrationrequests.course_id', $course_id)
->where('registrationrequests.registered', 1)
->get();
In the table registrationrequests
, I have columns for course_id
, user_id
and registered
(binary value). course_id
and user_id
are foreign keys for respective tables.
I'm getting an array of output. But it's not checking the condition where('registrationrequests.course_id', $course_id)
What might be the reason?