guild/common/models/Task.php
2021-11-23 13:13:19 +03:00

102 lines
2.6 KiB
PHP

<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "task".
*
* @property int $id
* @property int $project_id
* @property string $title
* @property int $status
* @property string $created_at
* @property string $updated_at
* @property int $project_user_id
* @property int $user_id
* @property string $description
*
* @property Project $project
* @property ProjectUser $projectUser
* @property User $user
* @property TaskUser[] $taskUsers
*/
class Task extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'task';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['project_id'], 'required'],
[['project_id', 'status', 'project_user_id', 'user_id'], 'integer'],
[['created_at', 'updated_at'], 'safe'],
[['title'], 'string', 'max' => 255],
[['description'], 'string', 'max' => 500],
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
[['project_user_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProjectUser::className(), 'targetAttribute' => ['project_user_id' => 'id']],
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'project_id' => 'Project ID',
'title' => 'Title',
'status' => 'Status',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
'project_user_id' => 'Project User ID',
'user_id' => 'User ID',
'description' => 'Description',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getProject()
{
return $this->hasOne(Project::className(), ['id' => 'project_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getProjectUser()
{
return $this->hasOne(ProjectUser::className(), ['id' => 'project_user_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getTaskUsers()
{
return $this->hasMany(TaskUser::className(), ['task_id' => 'id']);
}
}