/** * Creates a new HostsArtisticHelp model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new HostsArtisticHelp(); if ($model->load(Yii::$app->request->post()) && $model->save()) { $newmodel = HostsGeneralHelp::find()->where(['host_id' => $model->host_id])->one(); $newmodel->delete(); $newmodel1 = HostsProfessionalHelp::find()->where(['host_id' => $model->host_id])->one(); $newmodel1->delete(); $modelcount = HostsSkillDetails::find()->where(['host_id' => $model->host_id])->one(); if (count($modelcount) != 1) { return $this->redirect(['hostskilldetails/create', 'host_id' => $model->host_id]); } else { return $this->redirect(['hostskilldetails/update', 'id' => $modelcount->id]); } } else { return $this->render('create', ['model' => $model, 'host_id' => $_GET['host_id']]); } }
/** * Finds the HostsGeneralHelp model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return HostsGeneralHelp the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = HostsGeneralHelp::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
use app\models\HostsGeneralHelp; use app\models\HostsProfessionalHelp; use app\models\HostsArtisticHelp; /* @var $this yii\web\View */ /* @var $model app\models\AboutHostsLife */ $this->title = Yii::t('app', 'Create About Hosts Life'); $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'About Hosts Lives'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="about-hosts-life-create"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php $newmodel = HostsGeneralHelp::find()->where(['host_id' => $host_id])->one(); if (count($newmodel) != 1) { ?> <?php echo Html::a('General OR Professional Help', ['hostsgeneralhelp/create', 'host_id' => $host_id], ['class' => 'btn btn-success']); ?> <?php } else { ?> <?php echo Html::a('General OR Professional Help', ['hostsgeneralhelp/update', 'id' => $newmodel->id], ['class' => 'btn btn-success']); ?> <?php } ?> <?php