Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions app/Services/FollowerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down