update email template
This commit is contained in:
@@ -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,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user