$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'; } }