fix
This commit is contained in:
@@ -61,14 +61,22 @@ public function adminShow($id)
|
||||
public function adminUsers(Request $request)
|
||||
{
|
||||
$perPage = max(1, min((int) $request->input('per_page', 20), 100));
|
||||
$answered = $request->input('answered');
|
||||
|
||||
$users = User::select('id', 'first_name', 'last_name', 'age', 'gender', 'email', 'mobile', 'created_at', 'identifier')
|
||||
$query = User::select('id', 'first_name', 'last_name', 'age', 'gender', 'email', 'mobile', 'created_at', 'identifier')
|
||||
->withCount(['surveyAnswers as answers_count'])
|
||||
->withCount(['surveyAnswers as questions_answered' => function ($q) {
|
||||
$q->select(DB::raw('COUNT(DISTINCT survey_question_id)'));
|
||||
}])
|
||||
->orderByDesc('created_at')
|
||||
->paginate($perPage);
|
||||
->orderByDesc('created_at');
|
||||
|
||||
if ($answered === '1') {
|
||||
$query->has('surveyAnswers');
|
||||
} elseif ($answered === '0') {
|
||||
$query->doesntHave('surveyAnswers');
|
||||
}
|
||||
|
||||
$users = $query->paginate($perPage);
|
||||
|
||||
return response()->json($users);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user