1

该函数负责定义 laravel 5.1 认证中的用户名:

public function loginUsername()
{
    return property_exists($this, 'username') ? $this->username : 'email';
}

如果我将其修改为

public function loginUsername()
    {
        return property_exists($this, 'username') ? $this->username : 'username';
    }

在基础文件(并调整我的视图和数据库)中,这会在更新时持续存在吗?如果不是,我该如何覆盖它并单独保留基础文件?我已经为注册用户制作了一个新控制器,并且在我的路由中调用它而不是默认的,但是我发现很难对 postlogin 路由执行相同的操作。

4

1 回答 1

11

而不是在 trait 中修改它AuthenticatesUsers,你只需要在你的 : 上添加一个属性AuthController

protected $username = 'username';

于 2015-07-07T14:31:06.287 回答