Laravel 5.3 Eloquent transactions and foreign key restrictions

狂风中的少年 提交于 2019-12-06 10:35:49

Make sure CompanyUser has $fillable:

$fillable = ['user_id', 'company_id'];

Also, make sure there is a user with this ID is already in users table. Maybe you'll need to get rid of transaction.

Ok so we found a solution. It seems that we need to start transaction for each of schemas separately + each foreign key that are referencing different schema than their own should be created as deferred.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!