Files
sam-manage/app/Http/Requests/StoreUserRequest.php
hskwon d4534f0d3f feat(mng): 사용자 역할/부서 매핑 및 부서관리 복구/영구삭제 기능 추가
사용자 관리:
- 사용자 등록/수정 시 테넌트별 역할/부서 선택 기능 추가
- Department, UserRole, DepartmentUser 모델 추가
- User 모델에 역할/부서 관계 및 헬퍼 메서드 추가
- syncRoles/syncDepartments 메서드 (forceDelete로 유니크 키 충돌 방지)
- 체크박스 UI로 다중 선택 지원

부서 관리:
- Soft Delete 필터 (정상만/전체/삭제된 항목만)
- 복구(restore) 및 영구삭제(forceDelete) 기능 추가
- Department 모델에 SoftDeletes 트레이트 추가
- 삭제된 항목 빨간 배경 + "삭제됨" 배지 표시
2025-11-26 20:28:07 +09:00

75 lines
2.2 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreUserRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'user_id' => 'nullable|string|max:50|unique:users,user_id',
'name' => 'required|string|max:100',
'email' => 'required|email|max:255|unique:users,email',
'phone' => 'nullable|string|max:20',
'password' => 'required|string|min:8|confirmed',
'role' => 'nullable|string|max:50',
'is_active' => 'nullable|boolean',
'is_super_admin' => 'nullable|boolean',
'role_ids' => 'nullable|array',
'role_ids.*' => 'integer|exists:roles,id',
'department_ids' => 'nullable|array',
'department_ids.*' => 'integer|exists:departments,id',
];
}
/**
* Get custom attributes for validator errors.
*
* @return array<string, string>
*/
public function attributes(): array
{
return [
'user_id' => '사용자 ID',
'name' => '이름',
'email' => '이메일',
'phone' => '연락처',
'password' => '비밀번호',
'password_confirmation' => '비밀번호 확인',
'role' => '역할',
'is_active' => '활성 상태',
'is_super_admin' => '슈퍼 관리자',
];
}
/**
* Get custom messages for validator errors.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'email.unique' => '이미 사용 중인 이메일입니다.',
'user_id.unique' => '이미 사용 중인 사용자 ID입니다.',
'password.confirmed' => '비밀번호가 일치하지 않습니다.',
'password.min' => '비밀번호는 최소 8자 이상이어야 합니다.',
];
}
}