From 28f0497276bd943360d017b0ee3c8d8d2a0b20d5 Mon Sep 17 00:00:00 2001 From: Shlee Date: Wed, 4 Feb 2026 15:56:57 +1030 Subject: [PATCH] Update FollowerService.php --- app/Services/FollowerService.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Services/FollowerService.php b/app/Services/FollowerService.php index 9fff819ea..a76750977 100644 --- a/app/Services/FollowerService.php +++ b/app/Services/FollowerService.php @@ -36,8 +36,16 @@ public static function sync($pid) throw new \Exception("Profile with ID {$pid} not found"); } - $followers = Follower::whereFollowingId($pid)->count(); - $following = Follower::whereProfileId($pid)->count(); + // Only count followers/following where the related profile is active (status=1) + $followers = Follower::whereFollowingId($pid) + ->join('profiles', 'followers.profile_id', '=', 'profiles.id') + ->where('profiles.status', 1) + ->count(); + + $following = Follower::whereProfileId($pid) + ->join('profiles', 'followers.following_id', '=', 'profiles.id') + ->where('profiles.status', 1) + ->count(); $affected = Profile::where('id', $pid)->update([ 'followers' => $followers,