/** * Creates a new Scoutrelation model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Scoutrelation(); if ($model->load(Yii::$app->request->post())) { $thisuser = Yii::$app->user->getId(); $parent = Scoutparent::findOne(['userid' => $thisuser]); $model->parentid = $parent->id; if ($model->save()) { return $this->redirect(['scoutrelation/index']); } else { return $this->render('create', ['model' => $model]); } } else { return $this->render('create', ['model' => $model]); } }