Support the ongoing development of Laravel.io →
Requests Database
Last updated 1 year ago.
0

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.

Last updated 1 year ago.
0

Request to please help on these as this i very important for continuing my project.

Last updated 1 year ago.
0

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.

Last updated 1 year ago.
0

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.

Last updated 1 year ago.
0

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 :)

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.