ldc-doux/app/Mail/SendContactMail.php
Olivier Legat fee051a7de Squashed commit of the following:
commit c87deb1d185b5cce65e417fde124a2691e268355
Author: Sebastien Hattry <sebastien.hattry@ldc.fr>
Date:   Wed Apr 13 10:58:17 2022 +0200

    Fix bug when product not published but display

commit 93de503ce91b3f36251f00340344046aa8218b36
Author: Sebastien Hattry <sebastien.hattry@ldc.fr>
Date:   Wed Apr 13 10:57:11 2022 +0200

    Product in BO - Gamme required setting

commit b1da45a5fba0c4a8aacbe10d06ada6ef93e748a0
Author: Sebastien Hattry <sebastien.hattry@ldc.fr>
Date:   Tue Apr 12 17:45:21 2022 +0200

    Header - Size of search picture fix bug in IOS

commit 590772a2483be51dc9e89aa44822e20eb414dca6
Author: Sebastien Hattry <sebastien.hattry@ldc.fr>
Date:   Tue Apr 12 10:18:46 2022 +0200

    Slide - Remove title and text display in BO

commit 08daf95799ab591167f33dfad6a6fec37aa4090a
Author: Sebastien Hattry <sebastien.hattry@ldc.fr>
Date:   Tue Apr 12 10:13:41 2022 +0200

    form Contact : add drom list if france choose

commit f5ba031076bbb51655eaa2451bce06902191c116
Author: Sebastien Hattry <sebastien.hattry@ldc.fr>
Date:   Tue Apr 12 09:59:16 2022 +0200

    Add story line Svg if needed
2022-04-26 09:42:40 +02:00

101 lines
2 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 form data.
*/
protected $data;
/**
* The joined file name
*
* @var string
*/
protected $joinedFileName;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($data)
{
$this->data = $data;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$data = $this->data;
$this->joinFileIfProvided();
return $this->subject(
"Contact - " .
config('app.name', 'Doux') .
" - " .
$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(
'Doux_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;
}
}
}