property; if ($departure->lessThanOrEqualTo($arrival)) { throw new ReservationException('Die Abreise muss nach der Anreise liegen.'); } $booking = DB::transaction(function () use ($property, $channel, $arrival, $departure, $reference, $notes, $processingMode): Booking { $property->newQuery()->whereKey($property->id)->lockForUpdate()->firstOrFail(); if (! $this->availability->isAvailable($property, $arrival, $departure)) { throw ReservationException::notAvailable(); } $profile = $this->settings->resolve($property, $channel, IntakeKind::Inquiry); // v0.11 (B1): a portal request without the guest's details holds nothing until the details are there; the // offer hold comes with the offer. $draft = new Booking(['property_id' => $property->id, 'arrival' => $arrival->toDateString(), 'departure' => $departure->toDateString()]); $draft->setRelation('guest', null); return $property->bookings()->create([ ...RequestHold::for($draft, $profile), 'status' => BookingStatus::Reserved, 'source' => 'portal', 'intake' => IntakeKind::Inquiry, 'origin_channel_id' => $channel->id, 'portal_reference' => $reference, 'arrival' => $arrival->toDateString(), 'departure' => $departure->toDateString(), 'processing_mode' => $processingMode, 'internal_notes' => $notes, ]); }); app(CaseAutomation::class)->advance($booking); return $booking->refresh(); } }