id 的值始终"0" cpanel 上的 Laravel(拉拉维尔)



美好的一天 我有一个Laravel 7项目遇到了一些问题,首先我遇到了这个错误

我为该错误找到的解决方案是在config/database.php中将"严格"值编辑为 false。这修复了错误。但是现在我才意识到,每次我创建一个用户时,id的值总是"0"示例

这是我的迁移

public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->string('phone_number');
$table->string('client_address');
$table->rememberToken();
$table->timestamps();
});
}

这是因为您在表中id字段不是AuthoIncrement

首先删除数据库中users表,然后删除数据库中

migrations表中create_users_table记录,然后将迁移更改为此

$table->bigIncrements('id');

然后php artisan migrate

最新更新