大佬教程收集整理的这篇文章主要介绍了PHP-一般错误:1364栏位’identifier’没有预设值,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->integer('identifier')->unique();
$table->string('username')->unique();
$table->string('name');
$table->string('avatar');
$table->string('Trade')->nullable();
$table->decimal('funds')->default(0);
$table->enum('visibility', [1, 2, 3]);
$table->uuid('api_token');
$table->timestamps();
});
和
User::updateOrCreate([
'identifier' => 'dasdasd',
'username' => $user->nickname,
'name' => $user->name,
'avatar' => $user->avatar,
'visibility' => $user->visibility,
'api_token' => Uuid::generate()
]);
结果:sqlSTATE [HY000]:常规错误:1364字段’identifier’没有默认值(sql:插入用户(名称,Updated_at,created_at)值(GuilhermeAraújo,2017-03-26 20:39:04 ,2017-03-26 20:39:04))
怎么了?
解决方法:
'identifier' => 12345,
由于使用的是updateOrCreate(),因此应将标识符添加到$fillable数组中:
protected $fillable = ['identifier', ....];
以上是大佬教程为你收集整理的PHP-一般错误:1364栏位’identifier’没有预设值全部内容,希望文章能够帮你解决PHP-一般错误:1364栏位’identifier’没有预设值所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。