option('limit'); $restaurantId = $this->option('restaurant'); $this->info('Looking for deliveries that need rider assignment...'); $query = Delivery::query() ->where('status', DeliveryStatus::READY_FOR_PICKUP) ->whereNull('rider_id'); if ($restaurantId) { $query->where('restaurant_id', $restaurantId); } $deliveries = $query->limit($limit) ->orderBy('created_at', 'asc') ->get(); if ($deliveries->isEmpty()) { $this->info('No deliveries found that need rider assignment.'); return self::SUCCESS; } $this->info("Found {$deliveries->count()} deliveries to process."); $bar = $this->output->createProgressBar($deliveries->count()); $bar->start(); foreach ($deliveries as $delivery) { dispatch(new AssignRiderJob($delivery)); $bar->advance(); } $bar->finish(); $this->newLine(); $this->info("Dispatched {$deliveries->count()} assignment jobs to queue."); return self::SUCCESS; } }