Files
portal-api/app/Mail/CreateHosting.php
T
2025-07-24 16:18:27 +07:00

98 lines
2.7 KiB
PHP

<?php
namespace App\Mail;
use App\Models\Template;
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 CreateHosting 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 \Illuminate\Mail\Mailables\Envelope
*/
public function envelope()
{
return new Envelope(
subject: str_replace("{\$product_name}", $this->data['product_name'], $this->template->subject),
);
}
/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\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_password}",
"{\$service_password}",
"{\$ftp_account}",
"{\$ftp_password}",
],
[
$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_password'],
$this->data['service_due_exp'],
$this->data['ftp_account'],
$this->data['ftp_password'],
],
$this->template->message)
]
);
}
/**
* Get the attachments for the message.
*
* @return array
*/
public function attachments()
{
return [];
}
}