- data_requests: ein Beschaffungsvorgang je Vorgang mit Modus (automatisch / Freigabe / manuell), getrennten Zählern für Folgefragen und Erinnerungen ohne Rücksetzen, Antwortfrist ≠ Reservierungsfrist. - RequestCaseData: fragt nach, was für das nächste Angebot, die Wunschbestätigung oder (bei verbindlichen Buchungen) administrativ fehlt; ohne E-Mail keine Rückfrage. Teilantwort → gezielte Folgefrage, Schweigen → Erinnerungen, an der Grenze Aufgabe für die Vermieterin. Nie ein Hold. - Mail DataRequested mit Texten nach tatsächlichem Sperrstatus (M11); Dokumentart „Rückfrage“ – im Live-Betrieb ohne Freigabe nur nach Klick. - Signierter, versionierter Ergänzungslink (/angebot/angaben): Lesen schreibt nicht, Absenden über den Fakteneingang, idempotent. - Vorgang: „Rückfrage an den Gast senden“ / „Rückfrage beenden“; Eingangsbestätigung nennt die Klärungsreservierung korrekt. - Zeitplan: cases:data-requests alle fünf Minuten. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
88 lines
2.7 KiB
PHP
88 lines
2.7 KiB
PHP
<?php
|
||
|
||
namespace App\Models;
|
||
|
||
use App\Enums\DataRequestMode;
|
||
use App\Models\Concerns\BelongsToTenant;
|
||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||
use Illuminate\Database\Eloquent\Model;
|
||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
||
/**
|
||
* One coherent request for missing details of a case (v0.11, CH-16/17): at most one is open per case. Follow-up
|
||
* questions and reminders have separate counters that a partial answer never resets; the answer deadline is not a
|
||
* reservation deadline.
|
||
*/
|
||
#[Fillable(['booking_id', 'status', 'mode', 'purpose', 'fields', 'followups_sent', 'reminders_sent', 'link_version', 'last_message', 'last_sent_at', 'response_due_at', 'next_reminder_at', 'answered_at', 'closed_at', 'closed_reason'])]
|
||
class DataRequest extends Model
|
||
{
|
||
use BelongsToTenant;
|
||
|
||
/** Prepared, waits for the landlord's release. */
|
||
public const DRAFT = 'draft';
|
||
|
||
/** Sent; the guest is asked and may be reminded. */
|
||
public const OPEN = 'open';
|
||
|
||
/** The landlord asks himself (no automatic message), or the limits were reached. */
|
||
public const MANUAL = 'manual';
|
||
|
||
/** Every requested detail is there. */
|
||
public const COMPLETED = 'completed';
|
||
|
||
/** Ended without the details (case closed, landlord stopped it). */
|
||
public const STOPPED = 'stopped';
|
||
|
||
/** Statuses of a request that still runs. */
|
||
public const RUNNING = [self::DRAFT, self::OPEN, self::MANUAL];
|
||
|
||
/** First question. */
|
||
public const INITIAL = 'initial';
|
||
|
||
/** Targeted follow-up question after a partial or unclear answer. */
|
||
public const FOLLOWUP = 'followup';
|
||
|
||
/** Reminder when no answer came. */
|
||
public const REMINDER = 'reminder';
|
||
|
||
/**
|
||
* @return array<string, string>
|
||
*/
|
||
protected function casts(): array
|
||
{
|
||
return [
|
||
'mode' => DataRequestMode::class,
|
||
'fields' => 'array',
|
||
'last_sent_at' => 'immutable_datetime',
|
||
'response_due_at' => 'immutable_datetime',
|
||
'next_reminder_at' => 'immutable_datetime',
|
||
'answered_at' => 'immutable_datetime',
|
||
'closed_at' => 'immutable_datetime',
|
||
];
|
||
}
|
||
|
||
/**
|
||
* @return BelongsTo<Booking, $this>
|
||
*/
|
||
public function booking(): BelongsTo
|
||
{
|
||
return $this->belongsTo(Booking::class);
|
||
}
|
||
|
||
public function isRunning(): bool
|
||
{
|
||
return in_array($this->status, self::RUNNING, true);
|
||
}
|
||
|
||
public function statusLabel(): string
|
||
{
|
||
return match ($this->status) {
|
||
self::DRAFT => 'Rückfrage vorbereitet – wartet auf Ihre Freigabe',
|
||
self::OPEN => 'beim Gast angefragt',
|
||
self::MANUAL => 'von Ihnen nachzufragen',
|
||
self::COMPLETED => 'alle Angaben da',
|
||
default => 'beendet',
|
||
};
|
||
}
|
||
}
|