where('type', 'PushEvent')->count(); $pullRequestEventCount = $userData->where('type', 'PullRequestEvent')->count(); $issueCommentEventCount = $userData->where('type', 'IssueCommentEvent')->count(); // Calculations $otherEventsCount = $userData->count() - $pushEventCount - $pullRequestEventCount - $issueCommentEventCount; $selectedScore = $pushEventCount * 10 + $pullRequestEventCount * 5 + $issueCommentEventCount * 4; $totalScore = $otherEventsCount + $selectedScore; return $totalScore; }