/** * Creates a new CsProperties model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new CsProperties(); $model_trans = new CsPropertiesTranslation(); if ($model->load(Yii::$app->request->post()) and $model_trans->load(Yii::$app->request->post()) and $model->save()) { $model_trans->property_id = $model->id; $model_trans->lang_code = 'SR'; $model_trans->orig_name = $model->name; if ($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 getT() { return $this->hasMany(CsPropertiesTranslation::className(), ['property_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getTranslation() { $property_translation = \common\models\CsPropertiesTranslation::find()->where('lang_code="SR" and property_id=' . $this->id)->one(); if ($property_translation) { return $property_translation; } return false; }