Laravel question: How can I change the email field to username?

℡╲_俬逩灬. 提交于 2021-01-28 05:04:24

问题


I'm currently using the default Authentication of Laravel (php artisan make:auth)

But since it's very crucial for us to change the email-field to a username-field, I will need some help on that. I already tried to give it a shot, but I couldn't figure it out.

Help would be nice.


回答1:


As you can see in the authentication quickstart from the Laravel's Documentation at the "Username Customization" paragraph, you can easily customize the data that the user use to authenticate :

By default, Laravel uses the email field for authentication. If you would like to customize this, you may define a username method on your LoginController :

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


来源:https://stackoverflow.com/questions/52591165/laravel-question-how-can-i-change-the-email-field-to-username

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!