From 4eadecc08fae63e0ec6d3a864e0e2eaf93d6d5a1 Mon Sep 17 00:00:00 2001 From: FreeScout Date: Wed, 15 Feb 2023 03:52:36 -0800 Subject: [PATCH] Delete records from followers table when the user is deleted from DB --- app/Observers/UserObserver.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Observers/UserObserver.php b/app/Observers/UserObserver.php index 873c2605f..5b7637427 100644 --- a/app/Observers/UserObserver.php +++ b/app/Observers/UserObserver.php @@ -2,6 +2,7 @@ namespace App\Observers; +use App\Follower; use App\Mailbox; use App\Subscription; use App\User; @@ -40,5 +41,6 @@ public function creating(User $user) public function deleting(User $user) { $user->folders()->delete(); + Follower::whereIn('user_id', $user->id)->delete(); } }