I want to write an additional query inside, where in the condition and in the subquery there were conditions, checking the parent field of the request.
in the following way,
$query = DB::table('users'); $query->whereNotIn('users.id', function($query) use ($request) { $query->select('award_user.user_id') ->from('award_user') ->where('award_user.user_id', 'users.id') ->where('award_user.award_id', $request->award_id); });
Query is working fine, but
->where('award_user.user_id', 'users.id')
This line, user.id does not take from the parent request. If I specify the number manually, then it works correctly.
What is wrong with my request .. can you suggest.
source share