ldc-domaine-de-lanvaux/app/Mail/SendContactMail.php
2026-10-27 15:12:56 +01:00

91 lines
1.9 KiB
PHP

<?php
/**
* Sender pour le contact
*
* @category Description
* @package Category
* @author Name <email@email.com>
* @license http://url.com MIT
* @link http://url.com
* phpcs:ignore PEAR.Commenting.FileComment.MissingVersion
*/
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
/**
* Undocumented class
*
* @category Description
* @package Category
* @author Name <email@email.com>
* @license http://url.com MIT
* @link http://url.com
*/
class SendContactMail extends Mailable
{
use Queueable;
use SerializesModels;
/**
* The joined file name
*
* @var string
*/
protected $joinedFileName;
/**
* Create a new message instance.
*
* @param mixed $data
* @return void
*/
public function __construct(protected $data)
{
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$data = $this->data;
$this->joinFileIfProvided();
return $this->subject(
"Contact - " . config('app.name') . " - " . $data->topic
)
->from($data->email)
->view('emails.send-contact', compact('data'));
}
/**
* Attach a joined file if given in data
*
* @return void
*/
protected function joinFileIfProvided(): void
{
if ($this->data->file) {
$this->joinedFileName = sprintf(
'DOMAINEDELANVAUX_MESSAGE-PJ-%s.%s',
date("YmdHis"),
$this->data->file->extension()
);
$this->attach(
$this->data->file,
[
'as' => $this->joinedFileName,
'mime' => $this->data->file->getMimeType()
]
);
$this->data->file = $this->joinedFileName;
}
}
}