/** * Creates a new CsRegulations model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new CsRegulations(); $model_trans = new CsRegulationsTranslation(); if ($model->load(Yii::$app->request->post()) and $model_trans->load(Yii::$app->request->post())) { if ($model->save()) { $model_trans->regulation_id = $model->id; $model_trans->orig_name = $model->name; $model_trans->save(); return $this->redirect(['view', 'id' => $model->id]); } } else { return $this->render('create', ['model' => $model, 'model_trans' => $model_trans]); } }
/** * @return \yii\db\ActiveQuery */ public function getTranslation() { $regulation_translation = CsRegulationsTranslation::find()->where('lang_code="SR" and regulation_id=' . $this->id)->one(); if ($regulation_translation) { return $regulation_translation; } return false; }
/** * @return \yii\db\ActiveQuery */ public function getRegulationsTranslations() { return $this->hasMany(CsRegulationsTranslation::className(), ['lang_code' => 'code']); }