Files
fewo-stommer/app/Mail/PaymentReminder.php
2026-10-23 07:14:25 +02:00

52 lines
1.8 KiB
PHP

<?php
namespace App\Mail;
use App\Models\Booking;
use App\Support\Settings;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
/**
* Payment request or reminder to the guest. Overdue reminders are copied to the landlord.
*/
class PaymentReminder extends Mailable
{
use Queueable, SerializesModels;
public const DEPOSIT_OVERDUE = 'deposit_overdue';
public const BALANCE_REQUEST = 'balance_request';
public const BALANCE_OVERDUE = 'balance_overdue';
public function __construct(public Booking $booking, public string $kind) {}
public function envelope(): Envelope
{
return new Envelope(
subject: match ($this->kind) {
self::BALANCE_REQUEST => "Restzahlung für Ihre Buchung {$this->booking->reference}",
default => "Zahlungserinnerung zu Ihrer Buchung {$this->booking->reference}",
},
replyTo: [new Address(config('fewo.owner.email'), config('fewo.owner.name'))],
bcc: $this->kind === self::BALANCE_REQUEST ? [] : array_map(fn (string $address): Address => new Address($address), Settings::notificationRecipients()),
);
}
public function content(): Content
{
return new Content(
markdown: 'mail.payment-reminder',
with: [
'amount' => $this->kind === self::DEPOSIT_OVERDUE && ! $this->booking->requiresFullPayment() ? $this->booking->openDeposit() : $this->booking->openAmount(),
'dueOn' => $this->kind === self::DEPOSIT_OVERDUE ? $this->booking->deposit_due_on : $this->booking->balance_due_on,
],
);
}
}