How to make login in login registration function generated by artisan make:auth query login in multiple fields?


In the framework of laravel, the login registration function generated by artisan make:auth can only be logged in through email, so how can the code be changed to enable it to log in with both user name and email as well as phone. After reading the relevant documents, I did not come up with a solution. Do the great gods know how to change it?

  1. It must be modified on the basis of make:auth.

  2. It is also ok to give the idea of modification.

The problem has been solved and the solution is as follows:
In the AuthController controller, add the following code below the two trait used

 * Set the variable name of "User Name" submitted by the front page at login as $login
 * @var string
 protected $username = 'login';
 * Rewrite the getCredentials method to obtain login data and judge the type of the first data
 * @param  Requset $request
 * @return array
 protected function getCredentials(Request $request){
 $login = $request -> get('login');
 $middle = filter_var($login, FILTER_VALIDATE_EMAIL) ?   'email' : 'name';
 $field = filter_var($login, FILTER_VALIDATE_INT) ?   'phone' : $middle;
 return [
 $field => $login,
 'password' => $request->get('password'),

This overiding method introduces the getCredentials method in the AuthenticatesUsers class introduced in the AuthenticatesAndRegistersUsers class. The function of this method is to return the $credentials array variable used by the attempt method authentication information called in the login method. Note that the $login variable corresponding to the final $field index variable must be consistent with the required fields in the users table in the database.