208 lines
5.2 KiB
PHP
208 lines
5.2 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Enums\Contact\CivilityEnum;
|
|
use App\Enums\Contact\ObjectEnum;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class SendContactForm extends Mailable
|
|
{
|
|
use Queueable;
|
|
use SerializesModels;
|
|
|
|
/**
|
|
* The civility.
|
|
*
|
|
* @var \App\Enums\Contact\CivilityEnum|null
|
|
*/
|
|
private $civility;
|
|
|
|
/**
|
|
* The first name.
|
|
*
|
|
* @var string|null
|
|
*/
|
|
private $first_name;
|
|
|
|
/**
|
|
* The last name.
|
|
*
|
|
* @var string|null
|
|
*/
|
|
private $last_name;
|
|
|
|
/**
|
|
* The society.
|
|
*
|
|
* @var string|null
|
|
*/
|
|
private $society;
|
|
|
|
/**
|
|
* The email.
|
|
*
|
|
* @var string
|
|
*/
|
|
private $email;
|
|
|
|
/**
|
|
* The phone.
|
|
*
|
|
* @var string|null
|
|
*/
|
|
private $phone;
|
|
|
|
/**
|
|
* The address.
|
|
*
|
|
* @var string|null
|
|
*/
|
|
private $address;
|
|
|
|
/**
|
|
* The postal code.
|
|
*
|
|
* @var string|null
|
|
*/
|
|
private $postal_code;
|
|
|
|
/**
|
|
* The city.
|
|
*
|
|
* @var string|null
|
|
*/
|
|
private $city;
|
|
|
|
/**
|
|
* The object.
|
|
*
|
|
* @var \App\Enums\Contact\ObjectEnum|null
|
|
*/
|
|
private $object;
|
|
|
|
/**
|
|
* The product name.
|
|
*
|
|
* @var string
|
|
*/
|
|
private $product_name;
|
|
|
|
/**
|
|
* The product date limit.
|
|
*
|
|
* @var string
|
|
*/
|
|
private $product_date_limit;
|
|
|
|
/**
|
|
* The product barcode.
|
|
*
|
|
* @var string
|
|
*/
|
|
private $product_barcode;
|
|
|
|
/**
|
|
* The product lot.
|
|
*
|
|
* @var string
|
|
*/
|
|
private $product_lot;
|
|
|
|
/**
|
|
* The product date consumption.
|
|
*
|
|
* @var string
|
|
*/
|
|
private $product_date_consumption;
|
|
|
|
/**
|
|
* The product_location.
|
|
*
|
|
* @var string
|
|
*/
|
|
private $product_location;
|
|
|
|
/**
|
|
* The message.
|
|
*
|
|
* @var string|null
|
|
*/
|
|
private $message;
|
|
|
|
/**
|
|
* The file.
|
|
*
|
|
* @var string|null
|
|
*/
|
|
private $file;
|
|
|
|
/**
|
|
* Create a new message instance.
|
|
*
|
|
* @param array $edition
|
|
* @return void
|
|
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
|
|
*/
|
|
public function __construct(array $edition)
|
|
{
|
|
// phpcs:enable
|
|
$this->civility = (isset($edition['civility'])) ? CivilityEnum::make(intval($edition['civility']))->label() : null;
|
|
$this->first_name = $edition['first_name'] ?? null;
|
|
$this->last_name = $edition['last_name'] ?? null;
|
|
$this->society = $edition['society'] ?? null;
|
|
$this->email = $edition['email'];
|
|
$this->phone = $edition['phone'] ?? null;
|
|
$this->address = $edition['address'] ?? null;
|
|
$this->postal_code = $edition['postal_code'] ?? null;
|
|
$this->city = $edition['city'] ?? null;
|
|
$this->object = (isset($edition['object'])) ? ObjectEnum::make(intval($edition['object']))->label() : null;
|
|
$this->product_name = $edition['product_name'];
|
|
$this->product_date_limit = $edition['product_date_limit'];
|
|
$this->product_barcode = $edition['product_barcode'];
|
|
$this->product_lot = $edition['product_lot'];
|
|
$this->product_date_consumption = $edition['product_date_consumption'];
|
|
$this->product_location = $edition['product_location'];
|
|
$this->message = $edition['message'] ?? null;
|
|
$this->file = $edition['file'] ?? null;
|
|
}
|
|
|
|
/**
|
|
* Build the message.
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function build()
|
|
{
|
|
$mail = $this->subject(\config('app.name') . ' - contact formulaire')
|
|
->markdown('emails.send-contact-form')
|
|
->with([
|
|
'civility' => $this->civility,
|
|
'first_name' => $this->first_name,
|
|
'last_name' => $this->last_name,
|
|
'society' => $this->society,
|
|
'email' => $this->email,
|
|
'phone' => $this->phone,
|
|
'address' => $this->address,
|
|
'postal_code' => $this->postal_code,
|
|
'city' => $this->city,
|
|
'object' => $this->object,
|
|
'product_name' => $this->product_name,
|
|
'product_date_limit' => $this->product_date_limit,
|
|
'product_barcode' => $this->product_barcode,
|
|
'product_lot' => $this->product_lot,
|
|
'product_date_consumption' => $this->product_date_consumption,
|
|
'product_location' => $this->product_location,
|
|
'message' => $this->message,
|
|
]);
|
|
if (isset($this->file)) {
|
|
$mail = $mail->attach($this->file->getRealPath(), [
|
|
'as' => $this->file->getClientOriginalName(),
|
|
'mime' => $this->file->getClientMimeType(),
|
|
]);
|
|
}
|
|
return $mail;
|
|
}
|
|
}
|