fix
This commit is contained in:
@@ -77,14 +77,20 @@ public function adminUsers(Request $request)
|
|||||||
// Accepts either local user ID or approagency identifier (UUID).
|
// Accepts either local user ID or approagency identifier (UUID).
|
||||||
public function adminUserShow($identifier)
|
public function adminUserShow($identifier)
|
||||||
{
|
{
|
||||||
$user = User::where('id', $identifier)
|
$query = User::query()
|
||||||
->orWhere('identifier', $identifier)
|
|
||||||
->select('id', 'first_name', 'last_name', 'age', 'gender', 'birthday', 'email', 'mobile', 'created_at')
|
->select('id', 'first_name', 'last_name', 'age', 'gender', 'birthday', 'email', 'mobile', 'created_at')
|
||||||
->withCount(['surveyAnswers as answers_count'])
|
->withCount(['surveyAnswers as answers_count'])
|
||||||
->withCount(['surveyAnswers as questions_answered' => function ($q) {
|
->withCount(['surveyAnswers as questions_answered' => function ($q) {
|
||||||
$q->select(DB::raw('COUNT(DISTINCT survey_question_id)'));
|
$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) {
|
if (!$user) {
|
||||||
abort(404);
|
abort(404);
|
||||||
|
|||||||
Reference in New Issue
Block a user