我正在尝试使用findOrCreate
方法更新或插入一行(如果项目不存在)
这是我的代码
Pickupaddress::firstOrCreate(
[
'art_id'=>$artId
],
[
'address_line1' => $request->addressLine1,
'address_line2' => $request->addressLine2,
'country' => $request->country,
'postal_code' => $request->postalCode,
'mobile_number' => $request->mobileNumber,
'region' => $request->region,
'art_id' => Auth::id()
]
);
但只更新了时间戳字段,所有其他列都填充了NULL
修改
在strict
中将false
值更新为config\database.php
,但它没有被提及
答案 0 :(得分:2)
您是否已在fillable
模型中将字段设置为Pickupaddress
?
根据您的帖子,它将类似于:
protected $fillable = [
'address_line1',
'address_line2',
'country',
'postal_code',
'mobile_number',
'region',
'art_id'
];