From 80ba523f926c4675af8dd6c97640017a28d690cc Mon Sep 17 00:00:00 2001 From: AmirmahdiNourkazemi Date: Sat, 6 Jun 2026 13:38:41 +0330 Subject: [PATCH] fix:refferral --- app/Http/Controllers/AdminController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 3e76696..69b5528 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -148,9 +148,11 @@ public function pendingReferralRewards(Request $request) { $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') ->whereNull('referral_subscription_granted_at') - ->having('referrals_count', '>=', $target) + ->has('referrals', '>=', $target) ->orderByDesc('referrals_count') ->get(['id', 'uuid', 'first_name', 'last_name', 'email', 'mobile', 'referral_code']);