whereIn('status', BookingStatus::holding()) ->where(fn ($query) => $query // A lapsed clarification hold (v0.11) only frees the calendar; the request stays open for its details. ->where(fn ($offer) => $offer->where('hold_expires_at', '<=', now())->where('hold_purpose', Booking::HOLD_OFFER)) // An information without a hold (package 7) ends when its link expires and the guest did not ask for the booking. ->orWhere(fn ($information) => $information->where('status', BookingStatus::Reserved)->whereNull('hold_expires_at') ->where('information_valid_until', '<=', now())->whereNull('wish_at'))) ->with(['guest', 'property']) ->get(); foreach ($expired as $booking) { $booking->update(['status' => BookingStatus::Expired]); Mail::to(Settings::notificationRecipients())->send(new ReservationExpired($booking)); } return $expired->count(); } }