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);