123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- namespace app\models\entity;
- use yii\db\ActiveRecord;
- class Tasks extends ActiveRecord
- {
-
- public static function tableName()
- {
- return '{{tasks}}';
- }
- public function getProject()
- {
- return $this->hasOne(ProjectsLocotech::class, ['id' => 'input_id']);
- }
-
- public function getAccounts()
- {
- return $this->hasOne(Accounts::class, ['id' => 'assignees_arr']);
- }
-
- public function getTasktypes()
- {
- return $this->hasOne(Tasktypes::class, ['id' => 'type']);
- }
-
- public function getTasktypesjobtype()
- {
- return $this->hasOne(TasktypesJobtype::class, ['tasktype_id' => 'type']);
- }
-
- public function getPhase()
- {
- return $this->hasMany(Phase::class, ['task_id' => 'id']);
- }
- public function getAsusgjob2launch()
- {
- return $this->hasOne(AsusgJob2Launch::class, ['id' => 'asusg_job_mapped_id']);
- }
- public function getCommandId()
- {
- if ($this->parent_id == 0) {
- return 0;
- }
- return $this->id;
- }
- public function getTaskId()
- {
- if ($this->parent_id == 0) {
- return $this->id;
- }
- return 0;
- }
- public function asArray()
- {
- return [
- 'command_id' => $this->getCommandId(),
- 'task_id' => $this->getTaskId(),
- 'scenario_id' => $this->scenario_id,
- 'command_name' => $this->tasktypes->name
- ];
- }
-
- public function getCommands()
- {
- return Tasks::findAll(['parent_id' => $this->id]);
- }
- }
|