fix(API): FormRequest 타입 및 검증 수정
- SendFcmRequest, PositionReorderRequest 수정 - TenantLogoUploadRequest, Salary Requests 수정 - StructureReview Requests 수정 - HandoverReport, SiteBriefing Requests 추가 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
84
app/Http/Requests/SiteBriefing/UpdateSiteBriefingRequest.php
Normal file
84
app/Http/Requests/SiteBriefing/UpdateSiteBriefingRequest.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\SiteBriefing;
|
||||
|
||||
use App\Models\Tenants\SiteBriefing;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateSiteBriefingRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
// 기본 정보
|
||||
'title' => 'sometimes|string|max:200',
|
||||
'description' => 'nullable|string|max:5000',
|
||||
|
||||
// 거래처/현장 연결
|
||||
'partner_id' => 'nullable|integer|exists:clients,id',
|
||||
'site_id' => 'nullable|integer|exists:sites,id',
|
||||
|
||||
// 일정 정보
|
||||
'briefing_date' => 'sometimes|date',
|
||||
'briefing_time' => 'nullable|string|max:10',
|
||||
'briefing_type' => ['nullable', 'string', Rule::in(SiteBriefing::TYPES)],
|
||||
'location' => 'nullable|string|max:200',
|
||||
'address' => 'nullable|string|max:255',
|
||||
|
||||
// 상태 정보
|
||||
'status' => ['nullable', 'string', Rule::in(SiteBriefing::STATUSES)],
|
||||
'bid_status' => ['nullable', 'string', Rule::in(SiteBriefing::BID_STATUSES)],
|
||||
'bid_date' => 'nullable|date',
|
||||
|
||||
// 참석자 정보 (JSON)
|
||||
'attendees' => 'nullable|array',
|
||||
'attendees.*.user_id' => 'nullable|integer|exists:users,id',
|
||||
'attendees.*.name' => 'required|string|max:50',
|
||||
'attendees.*.type' => 'required|string|in:internal,external',
|
||||
'attendees.*.company' => 'nullable|string|max:100',
|
||||
'attendees.*.phone' => 'nullable|string|max:20',
|
||||
'attendees.*.email' => 'nullable|email|max:100',
|
||||
'attendees.*.position' => 'nullable|string|max:50',
|
||||
'attendance_status' => ['nullable', 'string', Rule::in(SiteBriefing::ATTENDANCE_STATUSES)],
|
||||
|
||||
// 공사 정보
|
||||
'site_count' => 'nullable|integer|min:0',
|
||||
'construction_start_date' => 'nullable|date',
|
||||
'construction_end_date' => 'nullable|date|after_or_equal:construction_start_date',
|
||||
'vat_type' => ['nullable', 'string', Rule::in(SiteBriefing::VAT_TYPES)],
|
||||
|
||||
// 프론트엔드 호환성을 위한 필드 매핑
|
||||
'project_name' => 'nullable|string|max:200',
|
||||
'work_report' => 'nullable|string|max:5000',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 데이터 준비
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
// project_name이 있고 title이 없으면 project_name을 title로 사용
|
||||
if ($this->filled('project_name') && ! $this->filled('title')) {
|
||||
$this->merge(['title' => $this->project_name]);
|
||||
}
|
||||
|
||||
// work_report가 있고 description이 없으면 work_report를 description으로 사용
|
||||
if ($this->filled('work_report') && ! $this->filled('description')) {
|
||||
$this->merge(['description' => $this->work_report]);
|
||||
}
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'construction_end_date.after_or_equal' => '공사 종료일은 시작일 이후여야 합니다.',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user