From 7875faa8fd68b20e2ba3deb89b126e41722976ca Mon Sep 17 00:00:00 2001 From: FreeScout Date: Wed, 15 Feb 2023 03:45:07 -0800 Subject: [PATCH] Delete records from followers table when conversation is deleted - closes #2732 --- app/Conversation.php | 5 +++++ app/Observers/ConversationObserver.php | 1 + 2 files changed, 6 insertions(+) diff --git a/app/Conversation.php b/app/Conversation.php index 4d0e8b280..7893e6067 100644 --- a/app/Conversation.php +++ b/app/Conversation.php @@ -6,6 +6,7 @@ use App\Customer; use App\Mailbox; use App\Folder; +use App\Follower; use App\Thread; use App\User; use App\Events\UserAddedNote; @@ -1782,6 +1783,10 @@ public static function deleteConversationsForever($conversation_ids) // Delete threads. Thread::whereIn('conversation_id', $ids)->delete(); + + // Delete followers. + Follower::whereIn('conversation_id', $ids)->delete(); + // Delete conversations. Conversation::whereIn('id', $ids)->delete(); ConversationFolder::whereIn('conversation_id', $ids)->delete(); diff --git a/app/Observers/ConversationObserver.php b/app/Observers/ConversationObserver.php index ee46d3589..556f4b01d 100644 --- a/app/Observers/ConversationObserver.php +++ b/app/Observers/ConversationObserver.php @@ -37,6 +37,7 @@ public function created(Conversation $conversation) public function deleting(Conversation $conversation) { $conversation->threads()->delete(); + $conversation->followers()->delete(); \Eventy::action('conversation.deleting', $conversation); }