From c730e2547e453d6ae41c107480c713c0c748a5b7 Mon Sep 17 00:00:00 2001 From: Kavalar Date: Fri, 23 Nov 2018 16:20:49 +0300 Subject: [PATCH] fix project --- backend/modules/project/models/Project.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/modules/project/models/Project.php b/backend/modules/project/models/Project.php index 430d936..cc0c31a 100644 --- a/backend/modules/project/models/Project.php +++ b/backend/modules/project/models/Project.php @@ -67,14 +67,17 @@ class Project extends \common\models\Project ProjectUser::deleteAll(['project_id' => $this->id]); - foreach ($post['user'] as $item) { - $prUser = new ProjectUser(); - $prUser->project_id = $this->id; - $prUser->card_id = $item; + if($post['user']){ + foreach ($post['user'] as $item) { + $prUser = new ProjectUser(); + $prUser->project_id = $this->id; + $prUser->card_id = $item; - $prUser->save(); + $prUser->save(); + } } + parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub } } \ No newline at end of file