- IMAP-Abruf jede Minute (webklex/php-imap, ohne PHP-imap-Erweiterung) oder signierter Push von n8n - Parser für Buchungs-, Storno- und Anfrage-Mails (de/en), Buchungsnummer, An-/Abreise - Erkannte Buchungen werden sofort gesperrt und an handgepflegte Portale weitergegeben; Kalender-Abgleich übernimmt bzw. ersetzt Mail-Sperren - Unklare Mails: Prüf-Mail + Admin-Liste Portal-E-Mails mit Aktion Sperre anlegen - Überwachung des Postfachs in Monitor und /health/sync Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
||
|
||
namespace App\Models;
|
||
|
||
use App\Enums\PortalEmailStatus;
|
||
use App\Enums\PortalEmailType;
|
||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||
use Illuminate\Database\Eloquent\Model;
|
||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
||
/**
|
||
* A notification e-mail of a portal (e.g. "new booking" from FeWo-direkt) and what the system did with it.
|
||
* Only a short excerpt is stored, not the whole e-mail.
|
||
*/
|
||
#[Fillable(['channel_id', 'message_id', 'from', 'subject', 'received_at', 'type', 'status', 'starts_on', 'ends_on', 'reference', 'blocked_period_id', 'excerpt', 'note'])]
|
||
class PortalEmail extends Model
|
||
{
|
||
/**
|
||
* Get the attributes that should be cast.
|
||
*
|
||
* @return array<string, string>
|
||
*/
|
||
protected function casts(): array
|
||
{
|
||
return [
|
||
'type' => PortalEmailType::class,
|
||
'status' => PortalEmailStatus::class,
|
||
'received_at' => 'immutable_datetime',
|
||
'starts_on' => 'immutable_date',
|
||
'ends_on' => 'immutable_date',
|
||
];
|
||
}
|
||
|
||
/**
|
||
* @return BelongsTo<Channel, $this>
|
||
*/
|
||
public function channel(): BelongsTo
|
||
{
|
||
return $this->belongsTo(Channel::class);
|
||
}
|
||
|
||
/**
|
||
* @return BelongsTo<BlockedPeriod, $this>
|
||
*/
|
||
public function blockedPeriod(): BelongsTo
|
||
{
|
||
return $this->belongsTo(BlockedPeriod::class);
|
||
}
|
||
|
||
public function period(): ?string
|
||
{
|
||
return $this->starts_on && $this->ends_on ? $this->starts_on->format('d.m.Y').' – '.$this->ends_on->format('d.m.Y') : null;
|
||
}
|
||
}
|