P粉6708387352023-09-06 11:10:07
Have you tried the following:
$clients = User::select('id') ->where(function($query) use($member_id){ $query->where([['created_by',$membre_id],['role','Client']]) ->orWhere([['updated_by',$membre_id],['role','Client']]) }) ->whereNotExists(function($query) use($member_id){ $query->select(DB::raw('client_id')) ->from('factures') ->where('created_by',$member_id); }) ->get(); }
This answer only applies the OR
condition between the first and second conditions (created_by and updated_by) and its result is combined with the AND
of the third condition .