How to make a LOGIN in laravel for two fields

According to the standard in laravel, there is one field for username when logging in to the account. Here is for example now I have on site is worth entry on field number and as do to entry was on two fields this number and ik. The site has two fields at the entrance (phone number and password) you need to enter in the phone number not only the login number itself, but also the individual key (this is another field in the database) and log in to the account was successful. If this cannot be done then suggest an alternative two-field entry option

Author: user13469116, 2020-07-18

1 answers

In the file LoginController.php redefine the username method for which field to log in to. A small example for entering email and name

public function username(): string
{
   $login = request()->input('email');
   $field = filter_var($login, FILTER_VALIDATE_EMAIL) ? 'email' : 'name';
   request()->merge([$field => $login]);
   return $field;
} 
 0
Author: Rezus, 2020-07-18 10:00:11