onDelete('cascade') Vs. Using Model Events to Delete records

Posted 6 months ago by thebigk

I've been using model events to delete related records. For example, if a post model is deleted, I'd use deleting model event to delete all the comments on the post. It works fine.

I now discovered onDelete('cascade') ; which I can define in my migrations.

I'm wondering if having database handle record deletion is better approach over using model events?

What's your take?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.