I want to a user to be able to login with either username, email or phone from a single field
In my LoginController i tried
protected function credentials(Request $request)
{
if(is_numeric($request->get('email'))){
return ['phone'=>$request->get('email'),'password'=>$request->get('password')];
}
elseif (filter_var($request->get('email'))) {
return ['email' => $request->get('email'), 'password'=>$request->get('password')];
}
return $request->only($this->username(), 'password');
}
I'm able to login with phone and email but not username. when i change it to
protected function credentials(Request $request)
{
if(is_numeric($request->get('email'))){
return ['phone'=>$request->get('email'),'password'=>$request->get('password')];
}
elseif (filter_var($request->get('email'))) {
return ['username' => $request->get('email'), 'password'=>$request->get('password')];
}
return $request->only($this->email(), 'password');
}
I'm able to login with phone or username but not with email. How to achieve login any of the three phone, email or username. I'm using laravel 5.5 and i have not mentioned any rules.