System > Betrieb > Benachrichtigungen: offene Meldungen (Doppelbuchungen im Postfach, Portal-Aufgaben) nur einmal oder alle 1/2/3/7 Tage erneut senden; Tages- und/oder Wochenuebersicht mit waehlbarer Uhrzeit, Wochentag und Inhalt (Postfach, Anfragen, Neues, An-/Abreisen, Zahlungen, Portale, Bewertungen). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Enums\DigestSection;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
/**
|
|
* The landlord's daily or weekly summary of open points and news (SendDigests, DigestReport).
|
|
*/
|
|
class Digest extends Mailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
/**
|
|
* @param list<array{section: DigestSection, title: string, items: list<string>, more: int, url: string, link: string}> $sections
|
|
*/
|
|
public function __construct(public bool $weekly, public array $sections) {}
|
|
|
|
public function envelope(): Envelope
|
|
{
|
|
$title = $this->weekly ? 'Wochenübersicht KW '.now()->isoWeek() : 'Tagesübersicht '.now()->format('d.m.Y');
|
|
$count = array_sum(array_map(fn (array $section): int => count($section['items']) + $section['more'], $this->sections));
|
|
|
|
return new Envelope(
|
|
subject: $title.($count === 0 ? ': nichts Neues' : ": {$count} ".($count === 1 ? 'Punkt' : 'Punkte')),
|
|
);
|
|
}
|
|
|
|
public function content(): Content
|
|
{
|
|
return new Content(
|
|
markdown: 'mail.digest',
|
|
);
|
|
}
|
|
}
|