fix:템플릿 선택 시 PDF 파일 필수 해제 및 후속 업로드 지원

- create: 템플릿 선택 시 PDF required 제거, 안내 메시지 표시
- fields: PDF 없는 계약 시 업로드 UI 표시
- API: uploadPdf 엔드포인트 추가 (POST /{id}/upload-pdf)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-12 20:05:28 +09:00
parent c6116ad611
commit 9b119fa7c9
4 changed files with 74 additions and 2 deletions

View File

@@ -354,6 +354,40 @@ public function download(int $id)
]);
}
/**
* PDF 업로드 (PDF 없이 생성된 계약에 나중에 업로드)
*/
public function uploadPdf(Request $request, int $id): JsonResponse
{
$request->validate([
'file' => 'required|file|mimes:pdf|max:20480',
]);
$tenantId = session('selected_tenant_id', 1);
$contract = EsignContract::forTenant($tenantId)->findOrFail($id);
if ($contract->original_file_path) {
return response()->json(['success' => false, 'message' => '이미 PDF 파일이 존재합니다.'], 422);
}
$file = $request->file('file');
$filePath = $file->store("esign/{$tenantId}/contracts", 'local');
$contract->update([
'original_file_path' => $filePath,
'original_file_name' => $file->getClientOriginalName(),
'original_file_hash' => hash_file('sha256', $file->getRealPath()),
'original_file_size' => $file->getSize(),
'updated_by' => auth()->id(),
]);
return response()->json([
'success' => true,
'message' => 'PDF 파일이 업로드되었습니다.',
'data' => ['path' => $filePath, 'name' => $file->getClientOriginalName()],
]);
}
// ─── 필드 템플릿 관련 메서드 ───
/**