2024-07-02 22:55:37 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Prevention\Mails;
|
|
|
|
|
|
|
|
use App\Invoice\InvoiceSettings;
|
2024-07-04 23:54:37 +02:00
|
|
|
use App\Lib\Editor\EditorData;
|
2024-07-02 22:55:37 +02:00
|
|
|
use App\Prevention\Contracts\Preventable;
|
|
|
|
use Illuminate\Bus\Queueable;
|
2024-07-02 23:00:09 +02:00
|
|
|
use Illuminate\Mail\Attachment;
|
2024-07-02 22:55:37 +02:00
|
|
|
use Illuminate\Mail\Mailable;
|
|
|
|
use Illuminate\Mail\Mailables\Content;
|
|
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
|
|
|
|
class PreventionRememberMail extends Mailable
|
|
|
|
{
|
|
|
|
use Queueable, SerializesModels;
|
|
|
|
|
|
|
|
public InvoiceSettings $settings;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new message instance.
|
|
|
|
*/
|
2024-07-04 23:54:37 +02:00
|
|
|
public function __construct(public Preventable $preventable, public EditorData $bodyText)
|
2024-07-02 22:55:37 +02:00
|
|
|
{
|
|
|
|
$this->settings = app(InvoiceSettings::class);
|
2024-07-04 23:54:37 +02:00
|
|
|
$this->bodyText = $this->bodyText
|
|
|
|
->replaceWithList('wanted', collect($preventable->preventions())->map(fn ($prevention) => $prevention->text())->toArray());
|
2024-07-02 22:55:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the message envelope.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Mail\Mailables\Envelope
|
|
|
|
*/
|
|
|
|
public function envelope()
|
|
|
|
{
|
|
|
|
return (new Envelope(
|
|
|
|
subject: $this->preventable->preventableSubject(),
|
|
|
|
))->to($this->preventable->getMailRecipient()->email, $this->preventable->getMailRecipient()->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the message content definition.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Mail\Mailables\Content
|
|
|
|
*/
|
|
|
|
public function content()
|
|
|
|
{
|
|
|
|
return new Content(
|
|
|
|
markdown: $this->preventable->preventableLayout(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the attachments for the message.
|
|
|
|
*
|
2024-07-02 23:00:09 +02:00
|
|
|
* @return array<int, Attachment>
|
2024-07-02 22:55:37 +02:00
|
|
|
*/
|
2024-07-02 23:00:09 +02:00
|
|
|
public function attachments(): array
|
2024-07-02 22:55:37 +02:00
|
|
|
{
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|