关联模型创建子项出现错误,丢失关联 ID
复制的代码
版本是5.7
$installment->items()->create([
'sequence' => $i,
'base' => $base,
'fee' => $fee,
'due_date' => $dueDate,
]);
message: "SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'installment_id' cannot be null (SQL: insert into installment_items
(sequence
, base
, fee
, due_date
, *installmentid*
, updated_at
, created_at
) values (0, 418.75, 10.46, 2019-01-19 00:00:00, , 2019-01-18 19:56:21, 2019-01-18 19:56:21))"
推荐文章: