guild/common/models/ProjectUser.php
2021-11-23 14:58:28 +03:00

86 lines
1.8 KiB
PHP

<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "project_user".
*
* @property int $id
* @property int $project_id
* @property int $user_id
*
* @property Project $project
* @property User $user
* @property Task[] $tasks
* @property TaskUser[] $taskUsers
*/
class ProjectUser extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'project_user';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['project_id', 'user_id'], 'required'],
[['project_id', 'user_id'], 'integer'],
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'project_id' => 'Проект',
'user_id' => 'Сотрудник',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getProject()
{
return $this->hasOne(Project::className(), ['id' => 'project_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getTasks()
{
return $this->hasMany(Task::className(), ['project_user_id' => 'id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getTaskUsers()
{
return $this->hasMany(TaskUser::className(), ['project_user_id' => 'id']);
}
}