fix: pratonton guna koordinat form semasa, No. Sijil ikut toggle
- loadPreview() hantar semua nilai field (X, Y, font_size, color, align) ke endpoint - certificate_no disertakan hanya jika toggle showCertNo aktif - testGenerate() bina liveFields dari request, gabung dengan config tersimpan (supaya font_file & valign kekal dari config asal) - generatePreview() terima overrideFields optional — preview sentiasa refresh Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -71,19 +71,18 @@ class CertificateService
|
||||
}
|
||||
}
|
||||
|
||||
public function generatePreview(CertificateTemplate $template, string $sampleName, string $sampleNo = ''): string
|
||||
public function generatePreview(CertificateTemplate $template, string $sampleName, string $sampleNo = '', ?array $overrideFields = null): string
|
||||
{
|
||||
$templatePath = Storage::disk('local')->path($template->image_path);
|
||||
$image = $this->manager->decodePath($templatePath);
|
||||
$config = $template->config_json ?? [];
|
||||
$fields = $config['fields'] ?? [];
|
||||
$fields = $overrideFields ?? ($template->config_json['fields'] ?? []);
|
||||
|
||||
if (isset($fields['name'])) {
|
||||
$this->writeText($image, $sampleName, $fields['name']);
|
||||
}
|
||||
|
||||
if (isset($fields['certificate_no']) && $sampleNo) {
|
||||
$this->writeText($image, $sampleNo, $fields['certificate_no']);
|
||||
if (isset($fields['certificate_no'])) {
|
||||
$this->writeText($image, $sampleNo ?: 'ECT/2025/0001', $fields['certificate_no']);
|
||||
}
|
||||
|
||||
return $image->encode(new JpegEncoder(85))->toString();
|
||||
|
||||
Reference in New Issue
Block a user