dispatcher = $dispatcher; $this->scheduleRepository = $scheduleRepository; $this->taskRepository = $taskRepository; } /** * Process a schedule and push the first task onto the queue worker. * * @param \Pterodactyl\Models\Schedule $schedule * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function handle(Schedule $schedule) { $this->scheduleRepository->loadTasks($schedule); /** @var \Pterodactyl\Models\Task $task */ $task = $schedule->getRelation('tasks')->where('sequence_id', 1)->first(); $formattedCron = sprintf('%s %s %s * %s', $schedule->cron_minute, $schedule->cron_hour, $schedule->cron_day_of_month, $schedule->cron_day_of_week ); $this->scheduleRepository->update($schedule->id, [ 'is_processing' => true, 'next_run_at' => CronExpression::factory($formattedCron)->getNextRunDate(), ]); $this->taskRepository->update($task->id, ['is_queued' => true]); $this->dispatcher->dispatch( (new RunTaskJob($task->id, $schedule->id))->delay($task->time_offset) ); } }