无法更新记录,因为可以使用密钥

时间:2018-06-06 07:38:48

标签: laravel eloquent foreign-keys schema updating

我无法更新(不删除)记录,因为辅助表中的外键不允许我这样做。

我知道我可以禁用外键,但如果我更新"客户"我不认为这是一个很好的做法。表,没有任何FK到辅助的。

此问题的任何解决方案?

我的DB-Schema   DB Schema[1]

其中一个辅助表FK

One of the FK

我得到的错误

The error what I'm getting

这是我用来做这个的代码

  $customer = Customer::where('id', $id)->update($data);
  if($customer)
      return redirect('/customers/);

1 个答案:

答案 0 :(得分:0)

感谢#TheFallen帮助我。

在数组中我包含了自己记录的ID,所以我从数组中取出它,更新顺序正在使用活动的外键。

相关问题