guild/common/models/ProjectUser.php

86 lines
1.8 KiB
PHP
Raw Normal View History

2018-10-11 11:15:09 +03:00
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "project_user".
*
* @property int $id
* @property int $project_id
2021-11-23 14:58:28 +03:00
* @property int $user_id
2018-10-11 11:15:09 +03:00
*
* @property Project $project
2021-11-23 14:58:28 +03:00
* @property User $user
* @property Task[] $tasks
* @property TaskUser[] $taskUsers
2018-10-11 11:15:09 +03:00
*/
class ProjectUser extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'project_user';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
2021-11-23 14:58:28 +03:00
[['project_id', 'user_id'], 'required'],
[['project_id', 'user_id'], 'integer'],
2018-10-11 11:15:09 +03:00
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
2021-11-23 14:58:28 +03:00
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
2018-10-11 11:15:09 +03:00
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
2021-11-23 14:58:28 +03:00
'project_id' => 'Проект',
'user_id' => 'Сотрудник',
2018-10-11 11:15:09 +03:00
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getProject()
{
return $this->hasOne(Project::className(), ['id' => 'project_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
2021-11-23 14:58:28 +03:00
public function getUser()
2018-10-11 11:15:09 +03:00
{
2021-11-23 14:58:28 +03:00
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']);
2018-10-11 11:15:09 +03:00
}
}