guild/common/models/ProjectTaskUser.php

68 lines
1.6 KiB
PHP
Raw Normal View History

2021-11-23 13:13:19 +03:00
<?php
namespace common\models;
use yii\db\ActiveQuery;
2021-11-23 13:13:19 +03:00
/**
* This is the model class for table "task_user".
*
* @property int $id
* @property int $task_id
* @property int $project_user_id
*
* @property ProjectUser $projectUser
* @property ProjectTask $task
2021-11-23 13:13:19 +03:00
*/
class ProjectTaskUser extends \yii\db\ActiveRecord
2021-11-23 13:13:19 +03:00
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'project_task_user';
2021-11-23 13:13:19 +03:00
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['task_id', 'project_user_id'], 'required'],
['project_user_id', 'unique', 'targetAttribute' => ['task_id', 'project_user_id'], 'message'=>'Уже закреплён(ы) за задачей'],
2021-11-23 13:13:19 +03:00
[['project_user_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProjectUser::className(), 'targetAttribute' => ['project_user_id' => 'id']],
[['task_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProjectTask::className(), 'targetAttribute' => ['task_id' => 'id']],
2021-11-23 13:13:19 +03:00
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'task_id' => 'Задача',
'project_user_id' => 'Сотрудник',
2021-11-23 13:13:19 +03:00
];
}
/**
* @return ActiveQuery
2021-11-23 13:13:19 +03:00
*/
public function getProjectUser()
{
return $this->hasOne(ProjectUser::className(), ['id' => 'project_user_id']);
}
/**
* @return ActiveQuery
2021-11-23 13:13:19 +03:00
*/
public function getTask()
{
return $this->hasOne(ProjectTask::className(), ['id' => 'task_id']);
2021-11-23 13:13:19 +03:00
}
}