2026-08-31 12:05:37 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Mail;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
|
use Illuminate\Mail\Mailable;
|
|
|
|
|
use Illuminate\Mail\Mailables\Attachment;
|
|
|
|
|
use Illuminate\Mail\Mailables\Content;
|
|
|
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
|
|
|
|
|
|
class ContactNotification extends Mailable
|
|
|
|
|
{
|
|
|
|
|
use Queueable;
|
|
|
|
|
use SerializesModels;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param array<string, mixed> $data
|
|
|
|
|
* @param array{name: string, mime: string, content: string}|null $attachment
|
|
|
|
|
*/
|
|
|
|
|
public function __construct(
|
|
|
|
|
public readonly array $data,
|
|
|
|
|
public readonly ?array $attachment = null,
|
2026-08-31 12:40:30 +02:00
|
|
|
) {
|
|
|
|
|
}
|
2026-08-31 12:05:37 +02:00
|
|
|
|
|
|
|
|
public function envelope(): Envelope
|
|
|
|
|
{
|
|
|
|
|
return new Envelope(
|
2026-09-03 11:29:57 +02:00
|
|
|
subject: 'Nouveau message - Formulaire de contact',
|
2026-08-31 12:05:37 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function content(): Content
|
|
|
|
|
{
|
|
|
|
|
return new Content(
|
|
|
|
|
view: 'emails.contact',
|
|
|
|
|
with: ['data' => $this->data],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return array<int, Attachment>
|
|
|
|
|
*/
|
|
|
|
|
public function attachments(): array
|
|
|
|
|
{
|
|
|
|
|
if ($this->attachment === null) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
Attachment::fromData(
|
|
|
|
|
fn () => base64_decode($this->attachment['content']),
|
|
|
|
|
$this->attachment['name'],
|
|
|
|
|
)->withMime($this->attachment['mime']),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|