/** * Creates a new CsActions model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new CsActions(); $model_trans = new CsActionsTranslation(); if ($model->load(Yii::$app->request->post()) and $model_trans->load(Yii::$app->request->post())) { if ($model->save()) { $model_trans->action_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() { $action_translation = CsActionsTranslation::find()->where('lang_code="SR" and action_id=' . $this->id)->one(); if ($action_translation) { return $action_translation; } return false; }
/** * Finds the CsServicesTranslation model based on its translated title. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return CsServices the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findActionByTitle($title) { if (($model = \common\models\CsActionsTranslation::find()->where('name=:name and lang_code="SR"', [':name' => str_replace('-', ' ', $title)])->one()) !== null) { return $model->action; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getActionsTranslations() { return $this->hasMany(CsActionsTranslation::className(), ['lang_code' => 'code']); }