Files
sam-api/app/Http/Requests/Employee/UpdateRequest.php
권혁성 7543fd2256 feat(WEB): 작업지시/출근부 기능 개선 및 마이그레이션 추가
- 작업지시 우선순위 필드 추가 (priority 마이그레이션)
- 수주-작업지시 품목 연동 source_order_item_id 컬럼 추가
- 수주 테이블에 account_code 필드 추가
- 작업지시 StoreRequest/UpdateRequest 우선순위 검증 추가
- WorkOrder 모델 priority fillable 추가
- 출근부 StoreRequest/UpdateRequest 검증 규칙 개선
- Employee Request 검증 규칙 수정
- SaleService/ItemService 수정
- WorkResultService 결과 처리 개선
- BankTransactionService 수정
- routes/api.php 엔드포인트 업데이트
- error.php 에러 메시지 추가

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 15:38:52 +09:00

86 lines
3.1 KiB
PHP

<?php
namespace App\Http\Requests\Employee;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
$employeeId = $this->route('id');
return [
// users 테이블 필드
'name' => 'nullable|string|max:100',
'email' => [
'nullable',
'email',
'max:255',
Rule::unique('users', 'email')->ignore($this->getOriginalUserId()),
],
'phone' => 'nullable|string|max:20',
'is_active' => 'nullable|boolean',
// tenant_user_profiles 테이블 필드
'department_id' => 'nullable|integer|exists:departments,id',
'position_key' => 'nullable|string|max:50',
'job_title_key' => 'nullable|string|max:50',
'work_location_key' => 'nullable|string|max:50',
'employment_type_key' => 'nullable|string|max:50',
'employee_status' => 'nullable|in:active,leave,resigned',
'manager_user_id' => 'nullable|integer|exists:users,id',
'profile_photo_path' => 'nullable|string|max:255',
'display_name' => 'nullable|string|max:100',
// json_extra 필드
'employee_code' => 'nullable|string|max:50',
'resident_number' => 'nullable|string|max:255',
'gender' => 'nullable|in:male,female',
'address' => 'nullable|array',
'address.zip_code' => 'nullable|string|max:10',
'address.address1' => 'nullable|string|max:255',
'address.address2' => 'nullable|string|max:255',
'salary' => 'nullable|numeric|min:0',
'hire_date' => 'nullable|date',
'rank' => 'nullable|string|max:50',
'bank_account' => 'nullable|array',
'bank_account.bank_name' => 'nullable|string|max:50',
'bank_account.account_number' => 'nullable|string|max:50',
'bank_account.account_holder' => 'nullable|string|max:50',
'work_type' => 'nullable|in:regular,contract,parttime,intern',
'contract_info' => 'nullable|array',
'contract_info.start_date' => 'nullable|date',
'contract_info.end_date' => 'nullable|date',
'contract_info.external_company' => 'nullable|string|max:100',
// 추가 json_extra 필드 (프론트엔드에서 전송)
'resignation_date' => 'nullable|date',
'resignation_reason' => 'nullable|string|max:500',
'clock_in_location' => 'nullable|string|max:255',
'clock_out_location' => 'nullable|string|max:255',
];
}
/**
* 현재 사원 프로필의 user_id 가져오기
*/
private function getOriginalUserId(): ?int
{
$employeeId = $this->route('id');
if (! $employeeId) {
return null;
}
$profile = \App\Models\Tenants\TenantUserProfile::find($employeeId);
return $profile?->user_id;
}
}