Files
website/app/Mail/PreApplicationMail.php

75 lines
1.7 KiB
PHP

<?php
namespace App\Mail;
use AllowDynamicProperties;
use App;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class PreApplicationMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*/
public function __construct(protected App\Models\PreApplications $pa, protected string $lang = 'de')
{
//
$this->locale($this->lang);
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
return new Envelope(
subject: __('mail.preapplication.subject'),
);
}
/**
* Get the message content definition.
*/
public function content(): Content
{
return new Content(
view: 'mail.preapplication',
with: ['pa' => $this->pa],
);
}
/**
* Get the attachments for the message.
*
* @return array<int, Attachment>
*/
public function attachments(): array
{
$langFb = match ($this->locale) {
'de' => 'dk',
'en' => 'ek',
default => 'dk',
};
$langDonation = match ($this->locale) {
'de' => '',
'en' => '_en',
};
return [
Attachment::fromPath(public_path('Dokumente/c3gov_fb5' . $langFb . '.pdf'))
->withMime('application/pdf'),
Attachment::fromPath(public_path('Dokumente/C3GovSpGV' . $langDonation . '.pdf'))
->withMime('application/pdf'),
];
}
}