From 5c6a771d7a8ad1aff0b4a20571aacd8f6afbb478 Mon Sep 17 00:00:00 2001 From: Amirmahdi Nourkazemi Date: Thu, 20 Aug 2026 16:51:07 +0330 Subject: [PATCH] fix --- app/Http/Controllers/SurveyQuestionController.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/SurveyQuestionController.php b/app/Http/Controllers/SurveyQuestionController.php index 30feff8..fa6cdd0 100644 --- a/app/Http/Controllers/SurveyQuestionController.php +++ b/app/Http/Controllers/SurveyQuestionController.php @@ -77,14 +77,20 @@ public function adminUsers(Request $request) // Accepts either local user ID or approagency identifier (UUID). public function adminUserShow($identifier) { - $user = User::where('id', $identifier) - ->orWhere('identifier', $identifier) + $query = User::query() ->select('id', 'first_name', 'last_name', 'age', 'gender', 'birthday', 'email', 'mobile', 'created_at') ->withCount(['surveyAnswers as answers_count']) ->withCount(['surveyAnswers as questions_answered' => function ($q) { $q->select(DB::raw('COUNT(DISTINCT survey_question_id)')); - }]) - ->first(); + }]); + + if (is_numeric($identifier)) { + $query->where('id', $identifier); + } else { + $query->where('identifier', $identifier); + } + + $user = $query->first(); if (!$user) { abort(404);