diff --git a/app/Http/Requests/Document/UpsertRequest.php b/app/Http/Requests/Document/UpsertRequest.php index 99c1920..dc7eba3 100644 --- a/app/Http/Requests/Document/UpsertRequest.php +++ b/app/Http/Requests/Document/UpsertRequest.php @@ -30,6 +30,9 @@ public function rules(): array 'data.*.field_key' => 'required_with:data|string|max:100', 'data.*.field_value' => 'nullable|string', + // HTML 스냅샷 + 'rendered_html' => 'nullable|string', + // 첨부파일 'attachments' => 'nullable|array', 'attachments.*.file_id' => 'required_with:attachments|integer|exists:files,id', diff --git a/app/Services/DocumentService.php b/app/Services/DocumentService.php index 6877956..2fef635 100644 --- a/app/Services/DocumentService.php +++ b/app/Services/DocumentService.php @@ -857,24 +857,32 @@ public function upsert(array $data): Document if ($existingDocument) { // UPDATE: 기존 update 로직 재사용 - return $this->update($existingDocument->id, [ + $updatePayload = [ 'title' => $data['title'] ?? $existingDocument->title, 'linkable_type' => 'item', 'linkable_id' => $itemId, 'data' => $data['data'] ?? [], 'attachments' => $data['attachments'] ?? [], - ]); + ]; + if (isset($data['rendered_html'])) { + $updatePayload['rendered_html'] = $data['rendered_html']; + } + return $this->update($existingDocument->id, $updatePayload); } // CREATE: 기존 create 로직 재사용 - return $this->create([ + $createPayload = [ 'template_id' => $templateId, 'title' => $data['title'] ?? '', 'linkable_type' => 'item', 'linkable_id' => $itemId, 'data' => $data['data'] ?? [], 'attachments' => $data['attachments'] ?? [], - ]); + ]; + if (isset($data['rendered_html'])) { + $createPayload['rendered_html'] = $data['rendered_html']; + } + return $this->create($createPayload); }); }