Files
portal-api/app/Mail/TicketCreated.php
T
2026-09-09 16:56:22 +07:00

59 lines
1.9 KiB
PHP

<?php
namespace App\Mail;
use App\Mail\Concerns\RequiresDbTemplate;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class TicketCreated extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels, RequiresDbTemplate;
public function __construct(
public readonly mixed $ticket,
public readonly mixed $customer,
) {}
public function envelope(): Envelope
{
return new Envelope(
subject: $this->renderFromTemplate('ticket_created', $this->vars())['subject'],
);
}
public function content(): Content
{
return new Content(
htmlString: $this->renderFromTemplate('ticket_created', $this->vars())['html'],
);
}
public function attachments(): array
{
return [];
}
private function vars(): array
{
$room = $this->ticket->room ?? null;
return [
'full_name' => trim("{$this->customer->firstname} {$this->customer->lastname}") ?: 'Quý khách',
'ticket_num' => $this->ticket->ticket_num,
'subject' => $this->ticket->subject,
'room_row' => $room
? '<tr><td style="font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: #666666; padding: 4px 0;" valign="top">Phòng ban:</td><td style="font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: #000000; padding: 4px 0;" valign="top">' . $room . '</td></tr>'
: '',
'ticket_url' => rtrim(config('app.frontend_url', ''), '/') . '/tickets/' . $this->ticket->ticket_num,
'app_name' => config('app.name', 'Thế Giới Số'),
'support_email' => 'support@tgs.com.vn',
'support_phone' => '(028) 7309. 7379',
];
}
}