From e4df6db1701b0fb9f2dd499855b84a14094800e6 Mon Sep 17 00:00:00 2001 From: AmirmahdiNourkazemi Date: Wed, 19 Aug 2026 12:25:01 +0330 Subject: [PATCH] fix --- app/Http/Controllers/AdminController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index ba88a7e..a1949c5 100755 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -184,7 +184,8 @@ public function authStats(Request $request) $daily = $base() ->selectRaw('DATE(created_at) as date') ->selectRaw('count(*) as total') - ->selectRaw('sum(sms_sent) as sms') + // Counted with a CASE rather than sum(sms_sent) — Postgres has no sum(boolean) + ->selectRaw('sum(case when sms_sent then 1 else 0 end) as sms') ->selectRaw("sum(case when event = ? then 1 else 0 end) as otp_sent", [AuthLog::EVENT_OTP_SENT]) ->selectRaw("sum(case when event = ? then 1 else 0 end) as otp_verified", [AuthLog::EVENT_OTP_VERIFIED]) ->selectRaw("sum(case when event = ? then 1 else 0 end) as otp_failed", [AuthLog::EVENT_OTP_FAILED]) @@ -204,7 +205,7 @@ public function authStats(Request $request) $byPackage = $base() ->whereNotNull('package_name') ->selectRaw('package_name') - ->selectRaw('sum(sms_sent) as sms') + ->selectRaw('sum(case when sms_sent then 1 else 0 end) as sms') ->selectRaw("sum(case when event in (?, ?, ?) then 1 else 0 end) as logins", [ AuthLog::EVENT_OTP_VERIFIED, AuthLog::EVENT_LOGIN,