public function registerChain()
    {
        /** @var ReportingTask $parentTask */
        $parentTask = null;
        $firstTask = true;
        $firstTaskId = null;
        foreach ($this->chainedQueue as $task) {
            /** @var ReportingTask $task */
            $task->model->output_file = $this->output_file;
            $task->model->delete_after_run = false;
            if ($task->registerTask()) {
                if (true === $firstTask) {
                    $firstTaskId = $task->model->id;
                    $firstTask = false;
                }
                if (null !== $parentTask) {
                    $parentTask->model->next_task_id = $task->model->id;
                    $parentTask->model->save('next_task_id');
                }
                $parentTask = $task;

            }
        }
        return $firstTaskId;
    }