Skip to content

Commit

Permalink
Delete records from followers table when conversation is deleted - cl…
Browse files Browse the repository at this point in the history
…oses #2732
  • Loading branch information
freescout-help-desk committed Feb 15, 2023
1 parent 35725c2 commit 7875faa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/Conversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions app/Observers/ConversationObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 7875faa

Please sign in to comment.