To query across tables with an OR relationship, you can use the orWhere method instead of where method. Here's how you can modify the code to achieve the desired result:
$users = $users->with('member')
->where(function($query) {
$query->where('email', '=', '')
->orWhereHas('member', function($member) {
$member->whereRaw('LENGTH(phone1) < 10');
});
})
->filter(request(['search']))
->orderBy("users.name")
->paginate(20);
In the above code, we have used the orWhere method to combine the two conditions. This will return the records where either the email is blank or the phone number is less than 10 characters long.