selectRaw('COUNT(id) as total') ->selectRaw('SUM(CASE WHEN email_verified_at IS NOT NULL THEN 1 ELSE 0 END) as verified') ->first(); $userTotal = (int) $stats->total; $userVerified = (int) ($stats->verified ?? 0); $userUnverified = $userTotal - $userVerified; $verificationRate = $userTotal > 0 ? round($userVerified / $userTotal * 100) : 0; return [ 'verified' => $userVerified, 'unverified' => $userUnverified, 'verification_rate' => $verificationRate, ]; } }