how to login using username instead of email in laravel nova?

前端 未结 4 1364
遥遥无期
遥遥无期 2021-01-14 10:35

In my existing laravel project, I handle logins with a username.

I\'ve already replaced email with username on app\\Nova\\User.php

please help me how can I d

4条回答
  •  我在风中等你
    2021-01-14 10:55

    for me it helped to use the loadViewsFrom method in the boot function of the NovaServiceProvider

    $this->loadViewsFrom(__DIR__.'/../resources/views/vendor/nova', 'nova');
    

    Just copy the templates needed to app/resources/views/vendor/nova/...

    See also: https://laravel.com/docs/5.6/packages#views

    This change in addition to the change in the user model should do most of the trick

    /**
    * Get the login username to be used by the controller.
    *
    * @return string
    */
    public function username()
    {
       return 'username';
    }
    

    regards,

    Andreas

提交回复
热议问题