M
M
Mo1she2018-08-13 14:47:20
SQL
Mo1she, 2018-08-13 14:47:20

SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails... Laravel 5.6.?

I have news and categories for them. Communication - many to many. When I try to delete the news, I get this error. Found a solution online by adding onDelete to the migration. But this method does not work with a many-to-many relationship, because there is nothing in the migration of news and categories, and the relationship is implemented only with the help of a linking table. Tell me, is there a way to beautifully solve this problem, or is it worth climbing into the linking table each time you delete the news and first deleting the record from there?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mo1she, 2018-08-13
@Mo1she

https://laravel.com/docs/5.4/eloquent-relationship...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question