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