コード例 #1
0
 /**
  * Creates a new CsUnits model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new CsUnits();
     $model_trans = new CsUnitsTranslation();
     if ($model->load(Yii::$app->request->post()) and $model_trans->load(Yii::$app->request->post())) {
         if ($model->save()) {
             $model_trans->unit_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]);
     }
 }
コード例 #2
0
ファイル: CsUnits.php プロジェクト: bokko79/servicemapp
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTranslation()
 {
     $unit_translation = CsUnitsTranslation::find()->where('lang_code="SR" and unit_id=' . $this->id)->one();
     if ($unit_translation) {
         return $unit_translation;
     }
     return false;
 }
コード例 #3
0
ファイル: CsLanguages.php プロジェクト: bokko79/servicemapp
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUnitsTranslations()
 {
     return $this->hasMany(CsUnitsTranslation::className(), ['lang_code' => 'code']);
 }