$guestData first_name and last_name are required, everything else optional * * @throws QuoteException * @throws ReservationException */ public function handle(Property $property, Channel $channel, StayRequest $stay, array $guestData, string $process = self::CONFIRM, ?string $portalReference = null, ?int $portalTotal = null, ?string $notes = null, bool $guestConfirmed = false): Booking { if ($channel->property_id !== $property->id) { throw new ReservationException('Der Kanal gehört nicht zu dieser Wohnung.'); } if ($process === self::CONTRACT && blank($guestData['email'] ?? null)) { throw new ReservationException('Für den sofortigen Vertragsversand wird die E-Mail-Adresse des Gastes benötigt.'); } $booking = $this->create->handle($property, $stay, $guestData, source: 'portal', sendMails: false); $changes = ['origin_channel_id' => $channel->id, 'portal_reference' => filled($portalReference) ? trim($portalReference) : null, 'internal_notes' => filled($notes) ? trim($notes) : $booking->internal_notes]; if ($guestConfirmed) { $changes['guest_confirmed_at'] = now(); } if ($portalTotal !== null) { $changes += $this->price->columns($property, $stay, $portalTotal); } $booking->update($changes); if ($process === self::RECORD) { return $booking->refresh(); } if ($process === self::CONTRACT) { $this->confirm->handle($booking, notifyGuest: true); } else { DB::transaction(fn () => $this->confirm->bind($booking)); } return $booking->refresh(); } }