我在更新功能中使用了它:
$qty = $request->input('checked_out_qty');
DB::table('consumables')->decrement('remaining_qty',$qty );
我不断收到此错误:
“SQLSTATE [23000]:完整性约束违规:1452 无法添加或更新子行:外键约束失败(fixed
. , consumables_histories
CONSTRAINT 251075_5c35eb169cb40
FOREIGN KEY ( checked_out_qty_id
) REFERENCES consumables
( ) ON DELETE CASCADE )( SQL :id
插入consumables_histories
(consumables_id
,,,,,,, , , ) 值 (1368, 6, 1, 1, 1, , 2019-02-03 08:08:34, 2019-02-03 08:08:34))checked_out_qty_id
checked_out_by_id
status_id
location_id
assigned_to_id
updated_at
created_at
但是当你第二次刷新时,减量仍然发生。我做错了什么?