option('event'); $events = Event::query(); if ($eventOpt) { $events->where('id', (int)$eventOpt); } else { // default: only events that are active/open (best effort) $events->where(function($q){ $q->whereNull('registration_close_at') ->orWhere('registration_close_at', '>=', now()->subDays(1)); }); } $ids = $events->pluck('id')->all(); $dispatched = 0; foreach ($ids as $eventId) { $pending = Registration::where('event_id', $eventId) ->where('status', 'CONFIRMED') ->whereDoesntHave('flightMember') ->count(); if ($pending > 0) { dispatch(new AssignPairingJob((int)$eventId)); $dispatched++; $this->info("Dispatched pairing job for event {$eventId} (pending {$pending})"); } } if ($dispatched === 0) { $this->line('No events require pairing.'); } return 0; } }