gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 04:58:54 25 4
gpt4 key购买 nike

在这个主题中,我问了一个问题:Laravel 5.2 auth change 'users' table

但是现在我的问题已经改变了。默认情况下,用户表具有id。但是我想要一个customer_id,所以我更改了所有内容,但不起作用。它不断询问id

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select * from klanten where id = 1 limit 1)



在表 klanten中,我有一个 customer_id,但它一直在询问 id

我已经改变的事情:

配置/认证
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
'table' => 'klanten',
],

创建了一个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();
});
}

如果我删除了时间戳,它也会不断询问 created_atupdated_at

Controller /Auth/AuthController
protected function validator(array $data)
{
return Validator::make($data, [
'voornaam' => 'required|max:255',
'email' => 'required|email|max:255|unique:klanten',
'password' => 'required|confirmed|min:6',
]);
}

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

应用/用户
protected $table = 'klanten';

protected $fillable = [
'voornaam', 'email', 'password',
];

我希望有人能帮助我!

最佳答案

编辑您的用户模型并添加以下内容:

protected $primaryKey = 'customer_id';

关于Laravel 5.2 auth将 'id'更改为 'customer_id',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34673901/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com