Need Assistance?

support@tutorialshub.in

Database Migrations & Seeding

Foreign Keys & Cascading Deletes

ADVERTISEMENT
Laravel Free Lesson
5 min read
ADVERTISEMENT

Use $table->foreignId('chapter_id')->constrained()->cascadeOnDelete(); to link child tables to parent tables cleanly. When a parent chapter is deleted, MySQL automatically deletes its child pages too.

ADVERTISEMENT
Hi, I'm Tuby! Here to help you