You did create a username field in the users table? Where there is email to login replace with username, and validate as text not email, that's all. It is really that simple.
Login by username in Laravel 5.3?
There are a lot of tutorials out there on how one can implement login with username instead of email addresses for past version of Laravel. However I can't quite get it working in Laravel 5.3 since I'm new to it all. I'm using the regular authentication system that you can generate with artisan make:auth.
- I edited my view form.
- Made DB migration with username field and all that, no problems on DB side I believe.
- Added "protected $username = 'username'" to my LoginController and RegisterController.
- Added rule to validator.
- Added username to $fillable so it's mass-assignable.
- Added error message for 'username' into language file.
When I try to login with username, the page refreshes and login page shows again without any errors or anything new. It doesn't log me in and doesn't redirect either. I believe the problem is in my view because of no returned errors but I could be wrong. Here is my form-group:
<div class="form-group{{ $errors->has('username') ? ' has-error' : '' }}">
<label for="username" class="col-md-3 control-label">Username</label>
<div class="col-md-9">
<input id="username" type="text" class="form-control" name="username" value="{{ old('username') }}" autofocus>
@if ($errors->has('username'))
<span class="help-block">
<strong>{{ $errors->first('username') }}</strong>
</span>
@endif
</div>
</div>
What could be the problem? Any help is appreciated.
Please or to participate in this conversation.