96 lines
2.6 KiB
PHP
96 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
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 CreateVirtualMachine extends Mailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
protected $template = null;
|
|
protected $data;
|
|
|
|
/**
|
|
* Create a new message instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($template = 0, $data = [])
|
|
{
|
|
$this->data = $data;
|
|
$this->template = Template::find($template);
|
|
}
|
|
|
|
/**
|
|
* Get the message envelope.
|
|
*
|
|
* @return Envelope
|
|
*/
|
|
public function envelope()
|
|
{
|
|
return new Envelope(
|
|
subject: str_replace("{\$os_name}", $this->data['os_name'], $this->template->subject),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get the message content definition.
|
|
*
|
|
* @return Content
|
|
*/
|
|
public function content()
|
|
{
|
|
return new Content(
|
|
view: 'emails.template',
|
|
with: [
|
|
'template' => str_replace(
|
|
[
|
|
"{\$company_name}",
|
|
"{\$company_logo}",
|
|
"{\$client_name}",
|
|
"{\$product_name}",
|
|
"{\$product_billing}",
|
|
"{\$product_price}",
|
|
"{\$service_host}",
|
|
"{\$service_username}",
|
|
"{\$service_port}",
|
|
"{\$service_password}",
|
|
"{\$os_name}",
|
|
"{\$service_due_exp}"
|
|
],
|
|
[
|
|
$this->data['company_name'],
|
|
$this->data['company_logo'],
|
|
$this->data['client_name'],
|
|
$this->data['product_name'],
|
|
$this->data['product_billing'],
|
|
$this->data['product_price'],
|
|
$this->data['service_host'],
|
|
$this->data['service_username'],
|
|
$this->data['service_port'],
|
|
$this->data['service_password'],
|
|
$this->data['os_name'],
|
|
$this->data['service_due_exp'],
|
|
],
|
|
$this->template->message)
|
|
]
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get the attachments for the message.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function attachments()
|
|
{
|
|
return [];
|
|
}
|
|
}
|