Hi @bashy

Thanks for your reply.

Typically, an idea came to me just after posting this question and think I've got it working now!

I created a new relationship with the added thisMonth query scope.

    public function referralsThisMonth()
        return $this->referrals()->thisMonth('referral_activated');

And then modified the controller method as follows:

    public function getTopReferrersThisMonth()
        return User::has('referralsThisMonth')
                    ->orderBy('referrals_this_month_count', 'desc')

Return to Thread...