Level 23
surely this should work? what you have already i mean. if someone deletes user, it will delete conversation & then messages...
in some case you could use events/observers too..
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
If I have 3 tables:
User, Conversation, Messages
Between User and conversation I have:
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
And between conversation and messages:
$table->foreign('conversation_id')
->references('id')
->on('conversations')
->onDelete('restrict');
If someone accidentally try to delete conversation, it should stop him because of messages restriction. But same way user is deleted I want to delete both conversation and messages.
How can I accomplish that?
Please or to participate in this conversation.