fix:refferral

This commit is contained in:
2026-06-06 13:38:41 +03:30
parent 6c602af9eb
commit 80ba523f92
+3 -1
View File
@@ -148,9 +148,11 @@ public function pendingReferralRewards(Request $request)
{ {
$target = User::REFERRAL_SUBSCRIPTION_TARGET; $target = User::REFERRAL_SUBSCRIPTION_TARGET;
// Use has() (a correlated subquery in WHERE) rather than having() on the
// withCount alias — Postgres does not allow select aliases in HAVING.
$users = User::withCount('referrals') $users = User::withCount('referrals')
->whereNull('referral_subscription_granted_at') ->whereNull('referral_subscription_granted_at')
->having('referrals_count', '>=', $target) ->has('referrals', '>=', $target)
->orderByDesc('referrals_count') ->orderByDesc('referrals_count')
->get(['id', 'uuid', 'first_name', 'last_name', 'email', 'mobile', 'referral_code']); ->get(['id', 'uuid', 'first_name', 'last_name', 'email', 'mobile', 'referral_code']);