- mailboxes (Modell für mehrere, eines aktiv): Übernahme des bisherigen Postfachs als „nur Portal-Mails“; Modus „alle Nachrichten“ für ein eigenes Postfach; Adresse als Antwortadresse der Rückfragen. - inbound_messages: jede Nachricht zuerst gespeichert, einmal je Message-ID, mit Testbetriebs-Kennzeichen (M10). Portal-Mails laufen unverändert über den Portalpfad (CH-08). - MessageMatcher (CH-13, ohne Scoring): Antwortbezug; Vorgangsnummer nur mit dem Gast als Absender; sonst Absender + Wohnung + beide Termine eines einzigen offenen Vorgangs. Ein offener Vorgang des Absenders allein genügt nicht (nur Hinweis). Alles andere → Klärung (M04). - Ausgehende Mails speichern ihre Message-ID; Antwort stoppt Erinnerungen. - Filament „Posteingang“: lesen, Vorgang zuordnen, als neue Anfrage anlegen, ignorieren, erledigt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Concerns\BelongsToTenant;
|
|
use App\Process\CaseLog;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* An e-mail that went out for a booking (communication log). Only subject and audience are kept.
|
|
*/
|
|
#[Fillable(['booking_id', 'audience', 'subject', 'message_id', 'sent_at'])]
|
|
class BookingMessage extends Model
|
|
{
|
|
public $timestamps = false;
|
|
|
|
use BelongsToTenant;
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::created(function (BookingMessage $message): void {
|
|
if ($message->booking !== null) {
|
|
CaseLog::record($message->booking, 'mail', 'E-Mail '.match ($message->audience) {
|
|
'guest' => 'an den Gast',
|
|
'landlord' => 'an uns',
|
|
default => 'im Testbetrieb an die Testadresse (nicht an den Gast)',
|
|
}.': '.$message->subject, actor: CaseLog::SYSTEM, at: $message->sent_at);
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return ['sent_at' => 'immutable_datetime'];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Booking, $this>
|
|
*/
|
|
public function booking(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Booking::class);
|
|
}
|
|
}
|