hasMany(JobLog::class, 'job_id'); } /** * @return Job::class[] */ public function children() { return $this->hasMany(Job::class, 'parent_id'); } /** * @return $this */ public function setRunning() { $this->setStatus(self::STATUS_RUNNING); return $this; } /** * @return $this */ public function setFinished() { $this->setStatus(self::STATUS_FINISHED); return $this; } /** * @return $this */ public function setWaiting() { $this->setStatus(self::STATUS_WAITING); return $this; } /** * @return $this */ public function setError() { $this->setStatus(self::STATUS_ERROR); return $this; } /** * @param $time * @return $this */ public function setRetryAfter($time) { $this->retry_after = $time; $this->save(); return $this; } /** * @param $status * @return $this */ public function setStatus($status) { $this->status = $status; $this->save(); return $this; } /** * @return $this */ public function increaseRetryCount() { $this->retry_count++; $this->save(); return $this; } }