Merge branch 'develop' into trunk
This commit is contained in:
commit
d696311558
3 changed files with 28 additions and 10 deletions
|
|
@ -41,14 +41,15 @@ class ContactController extends Controller
|
|||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
try {
|
||||
$data = new MailContactData(
|
||||
$request->safe()->except(['g-recaptcha-response', 'joinFile', 'locale'])
|
||||
);
|
||||
$locale = $request->input('locale');
|
||||
|
||||
$joinFilePath = ContactFormType::make($request->type)->hasFileInput()
|
||||
? $this->storeFile($request->file('joinFile'))
|
||||
: null;
|
||||
$data = new MailContactData(
|
||||
$request->safe()->except(['g-recaptcha-response', 'joinFile', 'locale']),
|
||||
$joinFilePath
|
||||
);
|
||||
|
||||
$locale = $request->input('locale');
|
||||
|
||||
// Send to Passerelle if it is a complain about a product.
|
||||
if (isset($locale) && ContactFormType::make($request->input('locale'))->equals(ContactFormType::nl)) {
|
||||
|
|
|
|||
|
|
@ -73,11 +73,7 @@ class ContactMail extends Mailable
|
|||
return [];
|
||||
}
|
||||
return [
|
||||
Attachment::fromPath($this->file)->as(sprintf(
|
||||
'LEGAULOIS_PASS_MESSAGE-PJ-%s.%s',
|
||||
date("YmdHis"),
|
||||
File::extension($this->file)
|
||||
)),
|
||||
Attachment::fromPath($this->file)->as($this->data->joinFile),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace App\Models;
|
|||
use App\Enums\ContactFormCivility;
|
||||
use App\Enums\ContactFormType;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
|
|
@ -100,6 +101,13 @@ class MailContactData extends Model
|
|||
'consumptionDateYear' => '0000',
|
||||
];
|
||||
|
||||
public function __construct(array $attributes = [], string $filePath = '')
|
||||
{
|
||||
parent::__construct($attributes);
|
||||
|
||||
$this->joinFile = self::getFileName($filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the model data to a Formatted Arcadia Data array.
|
||||
*
|
||||
|
|
@ -180,4 +188,17 @@ class MailContactData extends Model
|
|||
'TYPE_REPONSE' => 'mail'
|
||||
];
|
||||
}
|
||||
|
||||
private function getFileName(string $filePath): string
|
||||
{
|
||||
if (!File::exists($filePath)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'LEGAULOIS_PASS_MESSAGE-PJ-%s.%s',
|
||||
date("YmdHis"),
|
||||
File::extension($filePath)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue