/** * @return \yii\db\ActiveQuery */ public function getTranslation() { $process_translation = CsProcessesTranslation::find()->where('lang_code="SR" and process_id=' . $this->id)->one(); if ($process_translation) { return $process_translation; } return false; }
/** * Creates a new CsProcesses model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new CsProcesses(); $model_trans = new CsProcessesTranslation(); if ($model->load(Yii::$app->request->post()) and $model_trans->load(Yii::$app->request->post())) { if ($model->save()) { $model_trans->process_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]); } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * @return \yii\db\ActiveQuery */ public function getProcessesTranslations() { return $this->hasMany(CsProcessesTranslation::className(), ['lang_code' => 'code']); }