How can i login in laravel using the username in place of email address?

Go to Vendor\laravel\framework\src\Illuminate\Foundation\Auth\AuthenticatesUsers.php

Search for the method username and return name instead of email

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

Change the login field in login page to allow username as input value.

 
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}"> 
    <label for="name" class="col-md-4 control-label">Username</label> 
    <div class="col-md-6"> 
        <input id="name" type="name" class="form-control" name="name" value="{{ old('name') }}" required autofocus> 
        @if ($errors->has('name')) 
            <span class="help-block"> 
                <strong>{{ $errors->first('name') }}</strong> 
            </span> 
        @endif 
    </div> 
</div>  

Now you can login with your username.

Send Your Answer

The comment/answer feature from this section has been removed. Please visit our new section How can i login in laravel using the username in place of email address? to add comments or answer. Thankyou.