/** * Creates a new Donthuoc model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Donthuoc(); $model1 = ''; if (!empty($_GET['benhan'])) { $model1 = Donthuoc::find()->where(['maBA' => $_GET['benhan']])->one(); $model->maBA = $_GET['benhan']; } if (!empty($model1)) { return $this->redirect(['update', 'id' => $model1->id]); } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }