【发布时间】:2019-12-02 04:51:47
【问题描述】:
当我尝试插入用户归档时出现错误,
profile_image does not have a default value ,但我没有在此列中插入任何值
RegisterController.php
protected function create(array $data)
{
return Customer::create([
'first_name' => $data['name'],
'email' => $data['email'],
'customer_password' => hash('sha512', $data['password'])
]);
}
型号
protected $fillable = ['first_name','email','customer_password'];
架构
public function up()
{
DB::statement('ALTER TABLE customers MODIFY profile_image varchar(255) DEFAULT NULL');
}
为什么会这样???
谢谢。
【问题讨论】:
-
您能添加您的客户表架构吗?
-
@ϻᴇᴛᴀʟ 用架构更新了我的问题
-
您得到的错误与
ALTER TABLE语句一致,该语句添加了一个默认的 not 已经运行。因此,在添加新模型之前运行 alter 语句。 -
您是如何生成客户模型的?是基于
Customers表吗? -
@ϻᴇᴛᴀʟ 是的.....