with('tasks') ->whereRelation('server', fn (Builder $builder) => $builder->whereNull('status')) ->where('is_active', true) ->where('is_processing', false) ->where('next_run_at', '<=', now('UTC')->toDateTimeString()) ->get(); if ($schedules->count() < 1) { $this->line(__('commands.schedule.process.no_tasks')); return 0; } $bar = $this->output->createProgressBar(count($schedules)); foreach ($schedules as $schedule) { $bar->clear(); $this->processSchedule($processScheduleService, $schedule); $bar->advance(); $bar->display(); } $this->line(''); return 0; } /** * Processes a given schedule and logs and errors encountered the console output. This should * never throw an exception out, otherwise you'll end up killing the entire run group causing * any other schedules to not process correctly. */ protected function processSchedule(ProcessScheduleService $processScheduleService, Schedule $schedule): void { if ($schedule->tasks->isEmpty()) { return; } try { $processScheduleService->handle($schedule); $this->line(trans('command/messages.schedule.output_line', [ 'schedule' => $schedule->name, 'id' => $schedule->id, ])); } catch (Throwable $exception) { logger()->error($exception, ['schedule_id' => $schedule->id]); $this->error(__('commands.schedule.process.no_tasks') . " #$schedule->id: " . $exception->getMessage()); } } }