This is my Controller code:
public function searchUser(Request $request)
{
$pram = $request->name;
$data['users'] = User::whereHas('userBasicInfo', function ($query) use ($pram) {
$query->where('first_name', 'like', '%' . $pram . '%')
->orWhere('middle_name', 'like', '%' . $pram . '%')
->orWhere('last_name', 'like', '%' . $pram . '%');
})->with(['userBasicInfo' => function ($query) use ($pram) {
$query->where('first_name', 'like', '%' . $pram . '%')
->orWhere('middle_name', 'like', '%' . $pram . '%')
->orWhere('last_name', 'like', '%' . $pram . '%');
}])->get();
return $data;
}
I have relationship of user with userBasicInfo i can search with first_name, middle_name and last_name and my request parameter is name
Now i want to search with user email and there will be one more request parameter which is email and email is in users table
How i can search with user email as well i am confused here anyone please help me
Your help will be highly appreciated!