feat: [juil] 건설PMIS 좌측 사이드바 및 개인정보 관리 모달 구현
- PMIS 전용 좌측 사이드바 (사용자 프로필 + 네비게이션 메뉴) - 개인정보 관리 모달 (보기/수정 모드 전환) - 연락처, 이메일, 성별 편집 및 서버 저장 기능 - 프로필 조회/수정 JSON API 엔드포인트 추가 - 3컬럼 레이아웃 (좌측 사이드바 + 대시보드 + 우측 퀵메뉴)
This commit is contained in:
@@ -53,4 +53,52 @@ public function pmisWeather(WeatherService $weatherService): JsonResponse
|
||||
|
||||
return response()->json(['forecasts' => array_slice($forecasts, 0, 2)]);
|
||||
}
|
||||
|
||||
public function pmisProfile(): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
$tenantId = session('current_tenant_id', 1);
|
||||
|
||||
$departments = $user->getDepartmentsForTenant($tenantId);
|
||||
$roles = $user->getRolesForTenant($tenantId);
|
||||
|
||||
return response()->json([
|
||||
'user' => [
|
||||
'name' => $user->name,
|
||||
'user_id' => $user->user_id,
|
||||
'email' => $user->email,
|
||||
'phone' => $user->phone,
|
||||
'role' => $user->role,
|
||||
'profile_photo_path' => $user->profile_photo_path,
|
||||
'department' => $departments->first()?->name ?? '-',
|
||||
'position' => $user->getOption('position') ?? '-',
|
||||
'gender' => data_get($user->options, 'gender', ''),
|
||||
'role_names' => $roles->pluck('name')->join(', ') ?: '-',
|
||||
'created_at' => $user->created_at?->format('Y-m-d'),
|
||||
'last_login_at' => $user->last_login_at?->format('Y-m-d H:i'),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function pmisProfileUpdate(Request $request): JsonResponse
|
||||
{
|
||||
$request->validate([
|
||||
'phone' => ['nullable', 'string', 'max:20'],
|
||||
'email' => ['nullable', 'email', 'max:255'],
|
||||
'gender' => ['nullable', 'string', 'in:남,여'],
|
||||
]);
|
||||
|
||||
$user = auth()->user();
|
||||
$user->phone = $request->input('phone');
|
||||
$user->email = $request->input('email');
|
||||
|
||||
$options = $user->options ?? [];
|
||||
$options['gender'] = $request->input('gender');
|
||||
$user->options = $options;
|
||||
|
||||
$user->updated_by = $user->id;
|
||||
$user->save();
|
||||
|
||||
return response()->json(['success' => true, 'message' => '개인정보가 저장되었습니다.']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user