Files
fewo-stommer/app/Actions/ProvideGuestContact.php
T
LarsandClaude Sonnet 5.5 5ba9ae08ab
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m38s
Portal-Direktbuchung erfassen, Kontaktdaten-Prozess, manueller Statuswechsel, Archiv, Filter, Menue Verwaltung/Einrichtung
- Buchung erfassen: Buchungsweg Portal (Referenz, Portalpreis, ohne Kontaktdaten), Prozess bestaetigen/Vertrag sofort/nur erfassen
- Buchungsakte: Kontaktdaten eintragen (automatisch oder manuell weiter), Gast um Kontaktdaten bitten, Status von Hand aendern, Archivieren
- Liste: Filter Kanal, Anreisezeitraum, Kontaktdaten fehlen; Spalten ausblendbar; Archiv
- Klaerung: verstaendlichere Texte, eigenstaendige Belegung mit Kanal gilt als geklaert (Gitea #4)
- Akte per Button aus Liste und Belegungsplan erreichbar
- Menue: Gruppen Verwaltung (Tagesgeschaeft) und Einrichtung (Konfiguration), einfache Ansicht auf 8 Punkte

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 18:04:03 +01:00

68 lines
2.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Actions;
use App\Enums\BookingStatus;
use App\Exceptions\ReservationException;
use App\Models\Booking;
use App\Support\BookingProgress;
use Illuminate\Support\Arr;
/**
* The guest's contact data arrived (portal message, e-mail, phone) and is entered on the booking. The landlord chooses
* whether the process continues automatically – a binding portal booking gets its contract, a request gets the
* offer – or by hand (data only). An already existing e-mail confirmation of the guest can be recorded as well.
*/
class ProvideGuestContact
{
public const AUTOMATIC = 'automatic';
public const MANUAL = 'manual';
public function __construct(private ConfirmBooking $confirm, private SendOffer $offer) {}
/**
* @param array<string, ?string> $contact first_name, last_name, email, phone, street, postal_code, city, country
* @return string what was done, for the notification
*
* @throws ReservationException
*/
public function handle(Booking $booking, array $contact, string $process = self::MANUAL, bool $guestConfirmed = false): string
{
$contact = array_map(fn ($value) => filled($value) ? trim((string) $value) : null, Arr::only($contact, ['first_name', 'last_name', 'email', 'phone', 'street', 'postal_code', 'city', 'country']));
if (isset($contact['email'])) {
$contact['email'] = mb_strtolower($contact['email']);
}
if ($process === self::AUTOMATIC && blank($contact['email'] ?? $booking->guest?->email)) {
throw new ReservationException('Für den automatischen Ablauf wird die E-Mail-Adresse des Gastes benötigt.');
}
$booking->guest->update(array_filter($contact, fn ($value) => $value !== null));
if ($guestConfirmed) {
$booking->forceFill(['guest_confirmed_at' => $booking->guest_confirmed_at ?? now()])->saveQuietly();
}
$booking->refresh()->load('guest');
if ($process !== self::AUTOMATIC) {
return 'Kontaktdaten gespeichert';
}
if (in_array($booking->status, BookingStatus::occupying(), true)) {
$this->confirm->deliver($booking);
return 'Kontaktdaten gespeichert, Vertrag gesendet';
}
if (BookingProgress::kind($booking) === BookingProgress::PORTAL_BOOKING) {
$this->confirm->handle($booking);
return 'Kontaktdaten gespeichert, Buchung bestätigt und Vertrag gesendet';
}
$this->offer->handle($booking);
return 'Kontaktdaten gespeichert, Angebot gesendet';
}
}