63 lines
1.4 KiB
PHP
63 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Mail;
|
|
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Attachment;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Support\Facades\Config;
|
|
|
|
// NOTE: This should never be queued but sent directly
|
|
class RegateOrderMail extends Mailable
|
|
{
|
|
public function __construct(
|
|
private readonly string $csvContent,
|
|
private readonly string $fileName
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Get the message envelope.
|
|
*/
|
|
public function envelope(): Envelope
|
|
{
|
|
return new Envelope(
|
|
subject: sprintf(
|
|
'%s - %s',
|
|
Config::string('app.name'),
|
|
trans('An order was placed')
|
|
),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get the message content definition.
|
|
*/
|
|
public function content(): Content
|
|
{
|
|
return new Content(
|
|
htmlString: sprintf(
|
|
'%s. %s : %s',
|
|
trans('An order was placed'),
|
|
trans('Attachement filename'),
|
|
$this->fileName
|
|
),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get the attachments for the message.
|
|
*
|
|
* @return array<int, Attachment>
|
|
*/
|
|
public function attachments(): array
|
|
{
|
|
return [
|
|
Attachment::fromData(fn () => $this->csvContent, $this->fileName)
|
|
->withMime('text/csv'),
|
|
];
|
|
}
|
|
}
|