コード例 #1
0
 /**
  * Creates a new CsPropertyModels model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new CsPropertyValues();
     $model_trans = new CsPropertyValuesTranslation();
     if ($model->load(Yii::$app->request->post()) and $model_trans->load(Yii::$app->request->post())) {
         if ($model->save()) {
             if ($model->imageFile) {
                 $model->upload();
             }
             $model_trans->property_value_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
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTranslation()
 {
     $property_model_translation = CsPropertyValuesTranslation::find()->where('lang_code="SR" and property_value_id=' . $this->id)->one();
     if ($property_model_translation) {
         return $property_model_translation;
     }
     return false;
 }