I just got the same error and do not know how to fix it. I do know that the error is thrown because we are trying to delete a parent that has children.
Request to please help on these as this i very important for continuing my project.
This is an issue arising because of how you configured your model relationships, check how i did this one, it should be able to help you on that.
I'm assuming you have a many to many relationship with a pivot table in the middle.
Make sure you add onDelete('cascade') to your foreign key between the pivot table and the categories table
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
The issue is that you are deleting a row that another table (pivot table) is referencing through a foreign key.
Thanks evandertino and damienadermann.
I added ->onDelete('cascade') as solution given, then i ran command php artisan migrate:refresh php artisan db:seed
and tested to see it work :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community