each(function (Tenant $tenant) use ($autoOffer, $runner): void { $pending = Booking::query() ->where('status', BookingStatus::Reserved) ->where('offer_version', 0) ->where('information_version', 0) // Held requests while their hold runs; requests without a hold (information, package 7) for two weeks. ->where(fn ($query) => $query->where('hold_expires_at', '>', now())->orWhere(fn ($open) => $open->whereNull('hold_expires_at')->where('created_at', '>', now()->subDays(14)))) ->where(fn ($query) => $query->whereNull('intake')->orWhere('intake', 'inquiry')) ->with(['property', 'guest', 'importChannel', 'originChannel']) ->get() ->filter(fn (Booking $booking): bool => $autoOffer->applies($booking) && ($booking->isHoldActive() || ! $booking->process()->preReservation())); $sent = 0; foreach ($pending as $booking) { try { $result = $runner->advance($booking, 'schedule:bookings:auto-offers'); $sent += $result->ran('offer.binding') || $result->ran('offer.information') ? 1 : 0; } catch (Throwable) { // The request stays pending for the landlord; the next run tries again. } } $this->info("{$tenant->name}: {$sent} von {$pending->count()} Angebot(e) automatisch versendet."); }); return self::SUCCESS; } }