76 lines
1.8 KiB
PHP
76 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Models\MailContactData;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Mail\Mailables\Address;
|
|
|
|
class ContactMail extends Mailable
|
|
{
|
|
use Queueable;
|
|
use SerializesModels;
|
|
|
|
/**
|
|
* The order instance.
|
|
*
|
|
* @var \App\Models\MailContactData
|
|
*/
|
|
protected $data;
|
|
|
|
/**
|
|
* Create a new message instance.
|
|
*
|
|
* @param \App\Models\MailContactData $data
|
|
* @return void
|
|
*/
|
|
public function __construct(MailContactData $data)
|
|
{
|
|
$this->data = $data;
|
|
}
|
|
|
|
/**
|
|
* Get the message envelope.
|
|
*
|
|
* @return \Illuminate\Mail\Mailables\Envelope
|
|
*/
|
|
public function envelope(): \Illuminate\Mail\Mailables\Envelope
|
|
{
|
|
return new Envelope(
|
|
from: new Address(\config('mail.from.address'), \config('mail.from.name')),
|
|
subject: sprintf(
|
|
'%s - ' . config('app.name'),
|
|
ucfirst($this->data->enumType->label())
|
|
),
|
|
replyTo: [new Address($this->data->email, sprintf('%s %s', $this->data->firstname, $this->data->lastname))]
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get the message content definition.
|
|
*
|
|
* @return \Illuminate\Mail\Mailables\Content
|
|
*/
|
|
public function content(): \Illuminate\Mail\Mailables\Content
|
|
{
|
|
return new Content(
|
|
view: 'emails.contact',
|
|
text: 'emails.contact-text',
|
|
with: ['data' => $this->data]
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get the attachments for the message.
|
|
*
|
|
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
|
*/
|
|
public function attachments(): array
|
|
{
|
|
return [];
|
|
}
|
|
}
|