fix
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class SurveyQuestionController extends Controller
|
||||
@@ -127,6 +128,34 @@ public function adminUserShow($identifier)
|
||||
return response()->json($user);
|
||||
}
|
||||
|
||||
// ADMIN: update a user's profile fields from approagency data.
|
||||
public function adminUserUpdate(Request $request, $identifier)
|
||||
{
|
||||
if (is_numeric($identifier)) {
|
||||
$user = User::where('id', $identifier)->first();
|
||||
} else {
|
||||
$user = User::where('identifier', $identifier)->first();
|
||||
}
|
||||
|
||||
if (!$user) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$data = $request->validate([
|
||||
'first_name' => 'nullable|string',
|
||||
'last_name' => 'nullable|string',
|
||||
'age' => 'nullable|integer',
|
||||
'gender' => 'nullable|integer',
|
||||
'birthday' => 'nullable|string',
|
||||
'identifier' => 'nullable|string',
|
||||
'email' => 'nullable|email',
|
||||
]);
|
||||
|
||||
$user->update(array_filter($data, fn ($v) => !is_null($v)));
|
||||
|
||||
return response()->json($user);
|
||||
}
|
||||
|
||||
// ADMIN: clean aggregated results — per option vote counts & percentages, no raw rows.
|
||||
// Pass an $id for one question, omit it for all questions.
|
||||
public function adminAnalytics($id = null)
|
||||
|
||||
Reference in New Issue
Block a user