/**
  * @param int $project_id
  * @return ProjectMember
  * @throws ModelValidateException
  * @throws ForbiddenHttpException
  */
 public function actionCreate($project_id)
 {
     $project = Project::find()->byId($project_id)->oneOrThrow();
     if ($project->getOwnerId() != \Yii::$app->getUser()->getId()) {
         throw new ForbiddenHttpException();
         // todo-rbac
     }
     $data = \Yii::$app->getRequest()->post();
     $data['project_id'] = $project_id;
     $member = new ProjectMember();
     if ($member->create($data)) {
         return $member;
     } else {
         throw new ModelValidateException($member);
     }
 }
 public function init()
 {
     parent::init();
     $this->userTbl = User::tableName();
     $this->projectTbl = Project::tableName();
     $this->memberTbl = ProjectMember::tableName();
     $this->roleTbl = ProjectRole::tableName();
     $this->ticketTbl = Ticket::tableName();
     $this->ticketGroupTbl = TicketGroup::tableName();
     $this->tokenTbl = Token::tableName();
     $this->projectUserFk = $this->createFkData($this->projectTbl, 'owner_id', $this->userTbl, 'id', 'cascade', 'cascade');
     $this->memberUserFk = $this->createFkData($this->memberTbl, 'user_id', $this->userTbl, 'id', 'cascade', 'cascade');
     $this->memberRoleFk = $this->createFkData($this->memberTbl, 'role_id', $this->roleTbl, 'id', 'restrict', 'cascade');
     $this->memberProjectFk = $this->createFkData($this->memberTbl, 'project_id', $this->projectTbl, 'id', 'cascade', 'cascade');
     $this->ticketUserFk = $this->createFkData($this->ticketTbl, 'creator_id', $this->userTbl, 'id', 'cascade', 'cascade');
     $this->ticketGroupFk = $this->createFkData($this->ticketTbl, 'group_id', $this->ticketGroupTbl, 'id', 'restrict', 'cascade');
     $this->ticketProjectFk = $this->createFkData($this->ticketTbl, 'project_id', $this->projectTbl, 'id', 'cascade', 'cascade');
     $this->roleProjectFk = $this->createFkData($this->roleTbl, 'project_id', $this->projectTbl, 'id', 'cascade', 'cascade');
     $this->groupProjectFk = $this->createFkData($this->ticketGroupTbl, 'project_id', $this->projectTbl, 'id', 'cascade', 'cascade');
     $this->tokenUserFk = $this->createFkData($this->tokenTbl, 'user_id', $this->userTbl, 'id', 'cascade', 'cascade');
 }