Hi @user1980
You can group your where conditions like this:
$builder
->where(function($q) use ($adType, $liveAdOne, $liveAdTwo) {
$q
->whereIn('ad.ad_type', $adType)
->orWhereIn('ad.ad_one_id', $liveAdOne)
->when(!empty($liveAdTwo), function ($query) use ($liveAdTwo) {
return $query->orWhereIn('ad.ad_two_id', $liveAdTwo);
})
;
})
->where('ad.status', '=', 'active')