changed the creator for tasks from project_user to user, fixed api, documentation, filters, some other fixes
This commit is contained in:
@ -34,6 +34,7 @@ class ProjectUser extends \yii\db\ActiveRecord
|
||||
{
|
||||
return [
|
||||
[['project_id', 'user_id'], 'required'],
|
||||
['user_id', 'unique', 'targetAttribute' => ['user_id', 'project_id'], 'message'=>'Сотрудник уже занят на этом проекте'],
|
||||
[['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']],
|
||||
@ -69,7 +70,7 @@ class ProjectUser extends \yii\db\ActiveRecord
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
|
@ -18,12 +18,12 @@ use yii\helpers\ArrayHelper;
|
||||
* @property int $status
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property int $project_user_id
|
||||
* @property int $user_id_creator
|
||||
* @property int $user_id
|
||||
* @property string $description
|
||||
*
|
||||
* @property Project $project
|
||||
* @property ProjectUser $projectUser
|
||||
* @property User $userIdCreator
|
||||
* @property User $user
|
||||
* @property TaskUser[] $taskUsers
|
||||
*/
|
||||
@ -55,13 +55,13 @@ class Task extends \yii\db\ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['project_id', 'status', 'title', 'description', 'project_user_id'], 'required'],
|
||||
[['project_id', 'status', 'project_user_id', 'user_id'], 'integer'],
|
||||
[['project_id', 'status', 'title', 'description', 'user_id_creator',], 'required'],
|
||||
[['project_id', 'status', 'user_id_creator', '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_creator'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id_creator' => 'id']],
|
||||
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
|
||||
];
|
||||
}
|
||||
@ -78,7 +78,7 @@ class Task extends \yii\db\ActiveRecord
|
||||
'status' => 'Статус',
|
||||
'created_at' => 'Дата создания',
|
||||
'updated_at' => 'Дата обновления',
|
||||
'project_user_id' => 'Создатель',
|
||||
'user_id_creator' => 'Создатель задачи',
|
||||
'user_id' => 'Наблюдатель',
|
||||
'description' => 'Описание',
|
||||
];
|
||||
@ -100,14 +100,6 @@ class Task extends \yii\db\ActiveRecord
|
||||
return $this->hasOne(Project::className(), ['id' => 'project_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getProjectUser()
|
||||
{
|
||||
return $this->hasOne(ProjectUser::className(), ['id' => 'project_user_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
@ -116,6 +108,11 @@ class Task extends \yii\db\ActiveRecord
|
||||
return $this->hasOne(User::className(), ['id' => 'user_id']);
|
||||
}
|
||||
|
||||
public function getUserIdCreator()
|
||||
{
|
||||
return $this->hasOne(User::className(), ['id' => 'user_id_creator']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
|
@ -32,6 +32,7 @@ class TaskUser extends \yii\db\ActiveRecord
|
||||
{
|
||||
return [
|
||||
[['task_id', 'project_user_id'], 'integer'],
|
||||
['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']],
|
||||
];
|
||||
|
@ -230,4 +230,9 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
{
|
||||
return $this->hasMany(ManagerEmployee::className(), ['employee_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getProjectUser()
|
||||
{
|
||||
return $this->hasMany(ProjectUser::className(), ['user_id' => 'id']);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user