Добавление нового типа сущности, добавление владельца проект в список пользователей проекта

This commit is contained in:
2024-02-12 22:56:40 +03:00
parent 32a7f483fb
commit 1a250c4b00
4 changed files with 26 additions and 4 deletions

View File

@ -88,6 +88,25 @@ class Project extends \yii\db\ActiveRecord
];
}
/**
* @param $insert
* @param $changedAttributes
* @return void
*/
public function afterSave($insert, $changedAttributes): void
{
if ($insert) {
$model = new ProjectUser();
$model->user_id = $this->owner_id;
$model->project_id = $this->id;
$model->status = 1;
if ($model->save()) {
}
}
parent::afterSave($insert, $changedAttributes);
}
/**
* @return ActiveQuery
*/