- 마이그레이션 4개 (esign_contracts, esign_signers, esign_sign_fields, esign_audit_logs) - 모델 4개 (EsignContract, EsignSigner, EsignSignField, EsignAuditLog) - 서비스 4개 (EsignContractService, EsignSignService, EsignPdfService, EsignAuditService) - 컨트롤러 2개 (EsignContractController, EsignSignController) - FormRequest 4개 (ContractStore, FieldConfigure, SignSubmit, SignReject) - Mail 1개 (EsignRequestMail + 이메일 템플릿) - API 라우트 (인증 계약 관리 + 토큰 기반 서명 프로세스) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
59 lines
1.7 KiB
PHP
59 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Services\ESign;
|
|
|
|
use App\Models\ESign\EsignAuditLog;
|
|
use App\Services\Service;
|
|
|
|
class EsignAuditService extends Service
|
|
{
|
|
public function log(
|
|
int $contractId,
|
|
string $action,
|
|
?int $signerId = null,
|
|
?array $metadata = null
|
|
): EsignAuditLog {
|
|
$request = request();
|
|
|
|
return EsignAuditLog::create([
|
|
'tenant_id' => $this->tenantId(),
|
|
'contract_id' => $contractId,
|
|
'signer_id' => $signerId,
|
|
'action' => $action,
|
|
'ip_address' => $request?->ip(),
|
|
'user_agent' => $request?->userAgent() ? mb_substr($request->userAgent(), 0, 500) : null,
|
|
'metadata' => $metadata,
|
|
'created_at' => now(),
|
|
]);
|
|
}
|
|
|
|
public function logPublic(
|
|
int $tenantId,
|
|
int $contractId,
|
|
string $action,
|
|
?int $signerId = null,
|
|
?array $metadata = null
|
|
): EsignAuditLog {
|
|
$request = request();
|
|
|
|
return EsignAuditLog::withoutGlobalScopes()->create([
|
|
'tenant_id' => $tenantId,
|
|
'contract_id' => $contractId,
|
|
'signer_id' => $signerId,
|
|
'action' => $action,
|
|
'ip_address' => $request?->ip(),
|
|
'user_agent' => $request?->userAgent() ? mb_substr($request->userAgent(), 0, 500) : null,
|
|
'metadata' => $metadata,
|
|
'created_at' => now(),
|
|
]);
|
|
}
|
|
|
|
public function getContractLogs(int $contractId): \Illuminate\Database\Eloquent\Collection
|
|
{
|
|
return EsignAuditLog::where('contract_id', $contractId)
|
|
->with('signer:id,name,email,role')
|
|
->orderBy('created_at', 'desc')
|
|
->get();
|
|
}
|
|
}
|