小编Dra*_*ity的帖子

Laravel 5.2 auth将'id'更改为'customer_id'

在这个主题中,我问了一个问题:Laravel 5.2 auth更改'用户'表

但现在我的问题已经改变了.默认情况下,users表有一个id.但我想要一个customer_id,所以我改变了一切,但它不起作用.它不断要求id.

SQLSTATE [42S22]:未找到列:1054'where子句'中的未知列'id'(SQL:select*from klantenwhere id= 1 limit 1)

在表中klanten我有一个customer_id,但它一直在要求id.

我改变的事情:

配置/ AUTH

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
        'table' => 'klanten',
    ],
Run Code Online (Sandbox Code Playgroud)

创建了一个klanten迁移

public function up()
{
    Schema::create('klanten', function (Blueprint $table) {
        $table->increments('klant_id');
        $table->string('voornaam');
        $table->string('email')->unique();
        $table->string('password', 64);
        $table->rememberToken();
        $table->boolean('status');
        $table->timestamps();
    });
}
Run Code Online (Sandbox Code Playgroud)

如果我删除时间戳它一直要求created_atupdated_at太.

控制器/认证/ AuthController

protected function validator(array $data)
{ …
Run Code Online (Sandbox Code Playgroud)

authentication laravel laravel-5 laravel-5.2

8
推荐指数
1
解决办法
6805
查看次数

Laravel 5.2 auth更改'用户'表

我在Laravel中使用了新功能:

 php artisan make:auth
Run Code Online (Sandbox Code Playgroud)

但是当我注册它时users默认会使用数据库表,但我想将其更改为另一个表.默认情况下,它使用updated_atcreated_at在该表中,我也想删除它.

认证/ AuthController

protected function create(array $data)
{
    return User::create([
        'voornaam' => $data['voornaam'],
        'email' => $data['email'],
        'password' => bcrypt($data['password']),
    ]);
}
Run Code Online (Sandbox Code Playgroud)

应用程序\用户

protected $fillable = [
    'voornaam', 'email', 'password',
];
Run Code Online (Sandbox Code Playgroud)

这是我认为会改变它的东西,但它们没有.我希望有人可以告诉我更多关于这个问题的信息.

authentication laravel laravel-5 artisan laravel-5.2

6
推荐指数
2
解决办法
7279
查看次数