Files
sam-api/app/Http/Requests/Document/StoreRequest.php
권혁성 293330c418 feat: 문서 rendered_html 스냅샷 저장 지원
- Document 모델 $fillable에 rendered_html 추가
- DocumentService create/update에서 rendered_html 저장
- StoreRequest/UpdateRequest에 rendered_html 검증 추가
- WorkOrderService 검사문서/작업일지 생성 시 rendered_html 전달

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:28:53 +09:00

63 lines
2.4 KiB
PHP

<?php
namespace App\Http\Requests\Document;
use App\Models\Documents\DocumentAttachment;
use Illuminate\Foundation\Http\FormRequest;
class StoreRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
$attachmentTypes = implode(',', DocumentAttachment::TYPES);
return [
// 기본 정보
'template_id' => 'required|integer|exists:document_templates,id',
'title' => 'required|string|max:255',
'linkable_type' => 'nullable|string|max:100',
'linkable_id' => 'nullable|integer',
// 결재선 (보류 상태이지만 구조는 유지)
'approvers' => 'nullable|array',
'approvers.*.user_id' => 'required_with:approvers|integer|exists:users,id',
'approvers.*.role' => 'nullable|string|max:50',
// HTML 스냅샷
'rendered_html' => 'nullable|string',
// 문서 데이터 (EAV)
'data' => 'nullable|array',
'data.*.section_id' => 'nullable|integer',
'data.*.column_id' => 'nullable|integer',
'data.*.row_index' => 'nullable|integer|min:0',
'data.*.field_key' => 'required_with:data|string|max:100',
'data.*.field_value' => 'nullable|string',
// 첨부파일
'attachments' => 'nullable|array',
'attachments.*.file_id' => 'required_with:attachments|integer|exists:files,id',
'attachments.*.attachment_type' => "nullable|string|in:{$attachmentTypes}",
'attachments.*.description' => 'nullable|string|max:255',
];
}
public function messages(): array
{
return [
'template_id.required' => __('validation.required', ['attribute' => '템플릿']),
'template_id.exists' => __('validation.exists', ['attribute' => '템플릿']),
'title.required' => __('validation.required', ['attribute' => '제목']),
'title.max' => __('validation.max.string', ['attribute' => '제목', 'max' => 255]),
'approvers.*.user_id.exists' => __('validation.exists', ['attribute' => '결재자']),
'data.*.field_key.required_with' => __('validation.required', ['attribute' => '필드 키']),
'attachments.*.file_id.exists' => __('validation.exists', ['attribute' => '파일']),
];
}
}