[ 'class' => VerbFilter::className(), 'actions' => [ 'delete' => ['post'], ], ], ]; } /** * Lists all TerminLang models. * @return mixed */ public function actionIndex() { $searchModel = new TerminLangSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); } /** * Displays a single TerminLang model. * @param integer $termin_id * @param integer $lang_id * @return mixed */ public function actionView($termin_id) { return $this->render('view', [ 'model' => $this->findModel($termin_id, $lang_id), ]); } /** * Creates a new TerminLang model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $termin = new Termin(); $termin_lang = new TerminLang(); if ($termin_lang->load(Yii::$app->request->post())) { $termin->termin_id = ''; $termin->save(); $termin_lang->termin_id = $termin->termin_id; $termin_lang->save(); return $this->redirect(['index']); } else { return $this->render('create', [ 'termin_lang' => $termin_lang, 'termin' => $termin, ]); } } public function actionCreate_parent($termin_id) { $termin = new Termin(); $termin_lang = new TerminLang(); $termin_option = new TerminOption(); if ($termin_lang->load(Yii::$app->request->post())) { $termin->termin_id = ''; $termin->save(); // var_dump($termin->termin_id);die(); $termin_lang->termin_id = $termin->termin_id; $termin_lang->save(); $termin_option->termin_id = $termin->termin_id; $termin_option->termin_pid = $termin_id; $termin_option->save(); return $this->redirect(['index']); } else { return $this->render('create', [ 'termin_lang' => $termin_lang, 'termin' => $termin, ]); } } /** * Updates an existing TerminLang model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $termin_id * @param integer $lang_id * @return mixed */ public function actionUpdate($termin_id, $lang_id) { $model = $this->findModel($termin_id, $lang_id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'termin_id' => $model->termin_id, 'lang_id' => $model->lang_id]); } else { return $this->render('update', [ 'model' => $model, ]); } } /** * Deletes an existing TerminLang model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $termin_id * @param integer $lang_id * @return mixed */ public function actionDelete($termin_id, $lang_id) { $this->findModel($termin_id, $lang_id)->delete(); return $this->redirect(['index']); } /** * Finds the TerminLang model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $termin_id * @param integer $lang_id * @return TerminLang the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($termin_id, $lang_id) { if (($model = TerminLang::findOne(['termin_id' => $termin_id, 'lang_id' => $lang_id])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } }