Laravel 5.4 Auth寄存器更改表

时间:2017-03-15 01:24:44

标签: laravel-5.4

我通过添加

来更改默认表登录表

```的PHP     protected $ table =' client_table';

```

但是当尝试使用默认的laravel Auth注册表单时,它坚持使用表用户

3 个答案:

答案 0 :(得分:3)

您只需进行所做的更改,即:

protected $table = 'different_table';

如果使用注册功能,那么您还需要更改RegisterController的validator()函数:

'email' => 'required|string|email|max:255|unique:users',

应该成为:

'email' => 'required|string|email|max:255|unique:different_table',

答案 1 :(得分:0)

转到

  

配置/ auth.php

您应该修改以下代码:

/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
    ],

    // 'users' => [
    //     'driver' => 'database',
    //     'table' => 'users',
    // ],
],

您可能还需要修改RegisterController中的验证器方法。

答案 2 :(得分:0)

注册期间需要对受保护的功能验证器

进行小的更改

将“ unique:users”更改为“ unique:user”,如下所示 'email'=> ['required','string','email','max:255','unique:user'],