Dev/v1.2 (#4)
Co-authored-by: ISMAIL MASSERAN <topaz@Mac.dlinkrouter.local> Reviewed-on: #4
This commit was merged in pull request #4.
This commit is contained in:
@@ -56,11 +56,14 @@ class LetterService
|
||||
public function prepareViewData(array $overrides = []): array
|
||||
{
|
||||
$logoPath = $overrides['logoPath'] ?? config('mail.logo_path');
|
||||
$signaturePath = $overrides['signaturePath'] ?? config('letter.signature_path');
|
||||
|
||||
return array_merge([
|
||||
'letterLayout' => LetterLayout::resolve(),
|
||||
'logoPath' => $logoPath,
|
||||
'logoUrl' => $this->resolveLogoDataUri($logoPath),
|
||||
'logoUrl' => $this->resolveImageDataUri($logoPath),
|
||||
'signaturePath' => $signaturePath,
|
||||
'signatureUrl' => $this->resolveImageDataUri($signaturePath),
|
||||
'organizationAddress' => $overrides['organizationAddress'] ?? null,
|
||||
'organizationContact' => $overrides['organizationContact'] ?? null,
|
||||
], $overrides);
|
||||
@@ -97,14 +100,14 @@ class LetterService
|
||||
return $browsershot;
|
||||
}
|
||||
|
||||
protected function resolveLogoDataUri(?string $logoPath): ?string
|
||||
protected function resolveImageDataUri(?string $path): ?string
|
||||
{
|
||||
if (empty($logoPath) || ! file_exists($logoPath)) {
|
||||
if (empty($path) || ! file_exists($path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$mime = mime_content_type($logoPath) ?: 'image/svg+xml';
|
||||
$mime = mime_content_type($path) ?: 'image/svg+xml';
|
||||
|
||||
return 'data:'.$mime.';base64,'.base64_encode(file_get_contents($logoPath));
|
||||
return 'data:'.$mime.';base64,'.base64_encode(file_get_contents($path));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user