(パラメータ名「email_or_id」を受けて、メールアドレスの場合はメールアドレスとして認証。それ以外の場合はidとして認証に行きます。)
app/Http/Controllers/Auth/LoginController.php に以下を追加します
function username()
{
return 'email_or_id';
}
function attemptLogin(\Illuminate\Http\Request $request)
{
$email_or_id = $request->input($this->username());
$password = $request->input('password');
if (filter_var($email_or_id, \FILTER_VALIDATE_EMAIL)) {
$credentials = ['email' => $email_or_id, 'password' => $password];
} else {
$credentials = ['id' => $email_or_id, 'password' => $password];
}
return $this->guard()->attempt($credentials, $request->filled('remember'));
}
パラメータ名を「email」 →「email_or_id」に変更します resources/views/auth/login.blade.php を以下のように変更します
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" autofocus>
↓
<input id="email" type="text" class="form-control" name="email_or_id" value="{{ old('email_or_id') }}" autofocus>
以上で id またはメールアドレスでログインする事ができます
引用元 : https://goo.gl/Wodfh1