| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- namespace ThurData\Servers\KerioEmail\Core\Models\Tasks;
- use ThurData\Servers\KerioEmail\Core\Models\ExtendedEloquentModel;
- /**
- * Class Task
- * @property $status
- * @property job_id
- * @property $model
- * @property $namespace
- * @property $rel_id
- * @package ThurData\Servers\KerioEmail\Core\Models\Tasks
- */
- class Task extends ExtendedEloquentModel
- {
- const CANCELLED = 'cancelled';
- const FINISHED = 'finished';
- const STARTED = 'started';
- const PENDING = 'pending';
- /**
- * @var null
- */
- protected $model = null;
- /**
- * @return $this
- */
- public function finish()
- {
- $this->setStatus(self::FINISHED);
- return $this;
- }
- /**
- * @return $this
- */
- public function cancel()
- {
- $this->setStatus(self::CANCELLED);
- return $this;
- }
- /**
- * @return $this
- */
- public function pending()
- {
- $this->setStatus(self::PENDING);
- return $this;
- }
- /**
- * @return $this
- */
- public function start()
- {
- $this->setStatus(self::STARTED);
- return $this;
- }
- /**
- * @param $status
- * @return $this
- */
- public function setStatus($status)
- {
- $this->status = $status;
- $this->save();
- return $this;
- }
- /**
- * @param $id
- * @return $this
- */
- public function setJobId($id)
- {
- $this->job_id = $id;
- $this->save();
- return $this;
- }
- /**
- * @return mixed
- */
- public function model()
- {
- if(!$this->model)
- {
- $this->model = new $this->namespace($this->rel_id);
- }
- return $this->model;
- }
- }
|