update email template

This commit is contained in:
baodev0
2026-09-09 16:56:22 +07:00
parent d3d9f76ba0
commit 2365ef72e9
210 changed files with 6335 additions and 4688 deletions
+30 -14
View File
@@ -2,33 +2,49 @@
namespace App\Mail\Admin;
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 TicketAdminNotification extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
use Queueable, SerializesModels, RequiresDbTemplate;
public function __construct(
public readonly mixed $ticket,
public readonly mixed $customer,
) {}
public function build(): static
public function envelope(): Envelope
{
return $this
->subject("[ADMIN] Ticket mới #{$this->ticket->ticket_num} — {$this->customer->email}")
->view('emails.admin.ticket-notification')
->with([
'ticketNum' => $this->ticket->ticket_num,
'subject' => $this->ticket->subject,
'room' => $this->ticket->room,
'description' => strip_tags($this->ticket->description),
'customerName' => trim($this->customer->firstname . ' ' . $this->customer->lastname),
'customerEmail' => $this->customer->email,
'ticketUrl' => config('app.frontend_url') . '/tickets/' . $this->ticket->ticket_num,
]);
return new Envelope(
subject: $this->renderFromTemplate('admin_ticket_notification', $this->vars())['subject'],
);
}
public function content(): Content
{
return new Content(
htmlString: $this->renderFromTemplate('admin_ticket_notification', $this->vars())['html'],
);
}
private function vars(): array
{
$description = strip_tags($this->ticket->description ?? '');
return [
'ticket_num' => $this->ticket->ticket_num,
'subject_text' => $this->ticket->subject,
'room' => $this->ticket->room ?? 'N/A',
'customer_name' => trim($this->customer->firstname . ' ' . $this->customer->lastname) ?: 'N/A',
'customer_email'=> $this->customer->email,
'description' => mb_substr($description, 0, 500) . (mb_strlen($description) > 500 ? '…' : ''),
'ticket_url' => config('app.frontend_url') . '/tickets/' . $this->ticket->ticket_num,
];
}
}