whereIn('status', BookingStatus::holding()) ->where(fn ($query) => $query ->where('hold_expires_at', '<=', now()) // 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(); } }