Php Laravel 5.3:firstOrCreate不';t插入/更新值
我正在尝试使用Php Laravel 5.3:firstOrCreate不';t插入/更新值,php,laravel-5.3,Php,Laravel 5.3,我正在尝试使用findOrCreate方法更新或插入一行(如果项不存在)到表中 这是我的密码 Pickupaddress::firstOrCreate( [ 'art_id'=>$artId ], [ 'address_line1' => $request->addressLine1,
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填充
编辑
在
config\database.php
中将strict
值更新为false
,但它不起作用您在Pickupaddress
模型中将字段设置为可填充
根据你的帖子,可能是这样的:
protected $fillable = [
'address_line1',
'address_line2',
'country',
'postal_code',
'mobile_number',
'region',
'art_id'
];