70 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace common\models;
 | 
						|
 | 
						|
use Yii;
 | 
						|
use yii\base\InvalidConfigException;
 | 
						|
use yii\db\ActiveQuery;
 | 
						|
 | 
						|
/**
 | 
						|
 * 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 Task $task
 | 
						|
 */
 | 
						|
class TaskUser extends \yii\db\ActiveRecord
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * {@inheritdoc}
 | 
						|
     */
 | 
						|
    public static function tableName()
 | 
						|
    {
 | 
						|
        return 'task_user';
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * {@inheritdoc}
 | 
						|
     */
 | 
						|
    public function rules()
 | 
						|
    {
 | 
						|
        return [
 | 
						|
            [['task_id', 'project_user_id'], 'required'],
 | 
						|
            ['project_user_id', 'unique', 'targetAttribute' => ['task_id', 'project_user_id'], 'message'=>'Уже закреплён(ы) за задачей'],
 | 
						|
            [['project_user_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProjectUser::className(), 'targetAttribute' => ['project_user_id' => 'id']],
 | 
						|
            [['task_id'], 'exist', 'skipOnError' => true, 'targetClass' => Task::className(), 'targetAttribute' => ['task_id' => 'id']],
 | 
						|
        ];
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * {@inheritdoc}
 | 
						|
     */
 | 
						|
    public function attributeLabels()
 | 
						|
    {
 | 
						|
        return [
 | 
						|
            'id' => 'ID',
 | 
						|
            'task_id' => 'Задача',
 | 
						|
            'project_user_id' => 'Сотрудник',
 | 
						|
        ];
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * @return ActiveQuery
 | 
						|
     */
 | 
						|
    public function getProjectUser()
 | 
						|
    {
 | 
						|
        return $this->hasOne(ProjectUser::className(), ['id' => 'project_user_id']);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * @return ActiveQuery
 | 
						|
     */
 | 
						|
    public function getTask()
 | 
						|
    {
 | 
						|
        return $this->hasOne(Task::className(), ['id' => 'task_id']);
 | 
						|
    }
 | 
						|
}
 |