Reputation: 693
Receiving this error:
QueryException in Connection.php line 729:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`test`.`projects`, CONSTRAINT `projects_am_id_foreign` FOREIGN KEY (`am_id`) REFERENCES `employees` (`id`)) (SQL: insert into `projects` (`company`, `stage`, `status`, `jira`, `notes`, `updated_at`, `created_at`) values (Test, Waiting for Launch, In Progress, https://www.test.com, Testing, 2017-03-02 14:46:47, 2017-03-02 14:46:47))
Projects Table id company am_id etc etc
Employees Table id name department
I have the values in the other table so not sure why it can't reference them. Any ideas?
Upvotes: 0
Views: 1462
Reputation: 781
When you save your project Model, make sure the am_id is filled in.
Now you're trying to save a Project model without the am_id filled in => foreign key error
Upvotes: 2