$data */ protected function handleRecordCreation(array $data): Model { try { $property = Property::findOrFail($data['property_id']); $stay = new StayRequest( CarbonImmutable::parse($data['arrival']), CarbonImmutable::parse($data['departure']), (int) $data['guests'], promoCode: $data['promo_code'] ?: null, ); $guest = Arr::only($data, ['first_name', 'last_name', 'email', 'phone', 'street', 'postal_code', 'city']); if (filled($data['channel_id'] ?? null)) { $booking = app(RecordPortalBooking::class)->handle( $property, Channel::query()->findOrFail($data['channel_id']), $stay, $guest, $data['portal_process'] ?? RecordPortalBooking::CONFIRM, $data['portal_reference'] ?? null, filled($data['portal_total'] ?? null) ? (int) $data['portal_total'] : null, $data['internal_notes'] ?: null, (bool) ($data['guest_confirmed'] ?? false), ); return $booking; } $booking = app(CreateReservation::class)->handle($property, $stay, $guest, source: 'manual', sendMails: $data['send_mails']); if ($data['confirm_immediately']) { app(ConfirmBooking::class)->handle($booking, notifyGuest: $data['send_mails']); } } catch (QuoteException|ReservationException $exception) { Notification::make()->title('Buchung nicht möglich')->body($exception->getMessage())->danger()->send(); $this->halt(); } $booking->update(['internal_notes' => $data['internal_notes'] ?: null]); return $booking; } protected function getRedirectUrl(): string { return BookingResource::getUrl('view', ['record' => $this->getRecord()]); } }