Laravel Auth: Changed Login Checking from Email to Username

·

1 min read

By default, the login feature uses checking based on email instead of a username. Then what if we want to check based on username? Here's how.

On the file Controller\Auth\LoginController.php add the following methods:

public function username()
{
    return 'username';
}

in blade:

<input id="username" type="text" class="form-control @error('username') is-invalid @enderror" name="username" value="{{ old('username') }}" required autofocus>

Thanks!