feat: 사용자 관리 기능 및 MNG 문서 추가
- MNG_CRITICAL_RULES.md: DB 마이그레이션 금지 등 핵심 규칙 - UserController: 사용자 CRUD API 엔드포인트 - StoreUserRequest, UpdateUserRequest: 사용자 검증 - 사용자 관리 뷰: index, create, edit, table - 시스템 관리 메뉴 UI 개선 (테이블 헤더 스타일) - docs/INDEX.md: CRITICAL_RULES 링크 추가
This commit is contained in:
83
app/Http/Requests/UpdateUserRequest.php
Normal file
83
app/Http/Requests/UpdateUserRequest.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateUserRequest 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
|
||||
{
|
||||
$userId = $this->route('id');
|
||||
|
||||
return [
|
||||
'user_id' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:50',
|
||||
Rule::unique('users', 'user_id')->ignore($userId),
|
||||
],
|
||||
'name' => 'required|string|max:100',
|
||||
'email' => [
|
||||
'required',
|
||||
'email',
|
||||
'max:255',
|
||||
Rule::unique('users', 'email')->ignore($userId),
|
||||
],
|
||||
'phone' => 'nullable|string|max:20',
|
||||
'password' => 'nullable|string|min:8|confirmed',
|
||||
'role' => 'nullable|string|max:50',
|
||||
'is_active' => 'nullable|boolean',
|
||||
'is_super_admin' => 'nullable|boolean',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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자 이상이어야 합니다.',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user