Currently seeking new career opportunities in web development, particularly with Laravel, Hire Me

Laravel 5.3 login with username instead of email

David Carr

Laravel Framework

Laravel’s built in auth system uses an email address and password to validate credentials for cases where you want to use a username instead of an email address you can do the following:

Add a username column to the users table then add a username() method to App/Controllers/Auth/LoginController:

the default is email so place ‘username’ instead and this will be used instead of an email.

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

Next edit the login view and change the email field to a username field.

That’s it.

Laravel Modules Your Logo Your Logo Your Logo

Become a sponsor

Help support the blog so that I can continue creating new content!

Sponsor

My Latest Book

Modular Laravel Book - Laravel: The Modular way

Learn how to build modular applications with Laravel Find out more

Subscribe to my newsletter

Subscribe and get my books and product announcements.

Learn Laravel with Laracasts

Faster Laravel Hosting

© 2006 - 2024 DC Blog. All code MIT license. All rights reserved.