- 이메일 본문에 급여 내역 직접 노출 → PDF 첨부파일로 전환 (보안 강화) - barryvdh/laravel-dompdf 패키지 추가 - 이메일 본문은 간단한 안내 메시지로 변경 - dompdf에서 한글 렌더링을 위해 Noto Sans KR 폰트 적용
48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Attachment;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class PayslipMail extends Mailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
public function __construct(
|
|
public array $payslipData,
|
|
private string $pdfContent,
|
|
private string $fileName,
|
|
) {}
|
|
|
|
public function envelope(): Envelope
|
|
{
|
|
$year = $this->payslipData['pay_year'] ?? '';
|
|
$month = str_pad($this->payslipData['pay_month'] ?? '', 2, '0', STR_PAD_LEFT);
|
|
|
|
return new Envelope(
|
|
from: new \Illuminate\Mail\Mailables\Address('admin@codebridge-x.com', '(주)코드브릿지엑스'),
|
|
subject: "[SAM] {$year}년{$month}월분 급여명세서",
|
|
);
|
|
}
|
|
|
|
public function content(): Content
|
|
{
|
|
return new Content(
|
|
view: 'emails.payslip-notification',
|
|
);
|
|
}
|
|
|
|
public function attachments(): array
|
|
{
|
|
return [
|
|
Attachment::fromData(fn () => $this->pdfContent, $this->fileName)
|
|
->withMime('application/pdf'),
|
|
];
|
|
}
|
|
}
|