65 lines
1.5 KiB
PHP
65 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Mail\Customer;
|
|
|
|
use App\Models\Template;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class OrderCreated extends Mailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
protected Template $template;
|
|
protected array $data;
|
|
|
|
public function __construct(Template $template, array $data)
|
|
{
|
|
$this->template = $template;
|
|
$this->data = $data;
|
|
}
|
|
|
|
public function envelope(): Envelope
|
|
{
|
|
return new Envelope(
|
|
subject: $this->template->subject,
|
|
);
|
|
}
|
|
|
|
public function content(): Content
|
|
{
|
|
$message = str_replace(
|
|
[
|
|
'{\$company_name}',
|
|
'{\$company_logo}',
|
|
'{\$client_name}',
|
|
'{\$order_num}',
|
|
'{\$order_total}',
|
|
'{\$invoice_num}',
|
|
],
|
|
[
|
|
$this->data['company_name'],
|
|
$this->data['company_logo'],
|
|
$this->data['client_name'],
|
|
$this->data['order_num'],
|
|
$this->data['order_total'],
|
|
$this->data['invoice_num'],
|
|
],
|
|
$this->template->message
|
|
);
|
|
|
|
return new Content(
|
|
view: 'emails.template',
|
|
with: ['template' => $message],
|
|
);
|
|
}
|
|
|
|
public function attachments(): array
|
|
{
|
|
return [];
|
|
}
|
|
}
|