public function actionSave($id = null, $languageId = null)
    {
        if (empty($languageId)) {
            $languageId = Language::getCurrent()->id;
        }

        if (!empty($id)) {
            $model = PaymentMethod::findOne($id);
            if (empty($model)) throw new NotFoundHttpException();
            $modelTranslation = PaymentMethodTranslation::find()
                ->where(['payment_method_id' => $model->id, 'language_id' => $languageId])->one();
            if (empty($modelTranslation)) {
                $modelTranslation = new PaymentMethodTranslation();
            }
        }
        else {
            $model = new PaymentMethod();
            $modelTranslation = new PaymentMethodTranslation();
        }
        if (\Yii::$app->request->isPost) {

            if ($model->load(\Yii::$app->request->post())) {
                $imageModel = new PaymentImageModel();
                $imageModel->imageFile = UploadedFile::getInstance($model, 'image');

                if (!empty($imageModel->imageFile)) {
                    $uploadedImageName = $imageModel->upload();
                    $model->image = $uploadedImageName;
                }
            }

            if ($modelTranslation->load(Yii::$app->request->post())) {
                if ($modelTranslation->validate()) {
                    $model->save();
                    $modelTranslation->payment_method_id = $model->id;
                    $modelTranslation->language_id = $languageId;

                    $modelTranslation->save();
                    return $this->redirect(['save', 'id' => $model->id, 'languageId' => $languageId]);
                }
            }

        }
        return $this->render('save', [
            'model' => $model,
            'modelTranslation' => $modelTranslation,
            'selectedLanguage' => Language::findOne($languageId)
        ]);
    }
public function actionSave($id = null, $languageId = null)
    {
        if (empty($languageId)) {
            $languageId = Language::getCurrent()->id;
        }

        if (!empty($id)) {
            $model = PaymentMethod::findOne($id);
            if (empty($model)) throw new NotFoundHttpException();
            $modelTranslation = PaymentMethodTranslation::find()
                ->where(['payment_method_id' => $model->id, 'language_id' => $languageId])->one();
            if (empty($modelTranslation)) {
                $modelTranslation = new PaymentMethodTranslation();
            }
        }
        else {
            $model = new PaymentMethod();
            $modelTranslation = new PaymentMethodTranslation();
        }
        if (\Yii::$app->request->isPost) {

            if ($model->load(\Yii::$app->request->post())) {
                $imageModel = new PaymentImageModel();
                $imageModel->imageFile = UploadedFile::getInstance($model, 'image');

                if (!empty($imageModel->imageFile)) {
                    $uploadedImageName = $imageModel->upload();
                    $model->image = $uploadedImageName;
                }
            }

            if ($modelTranslation->load(Yii::$app->request->post())) {
                if ($modelTranslation->validate()) {
                    $model->save();
                    $modelTranslation->payment_method_id = $model->id;
                    $modelTranslation->language_id = $languageId;

                    $modelTranslation->save();
                    return $this->redirect(['save', 'id' => $model->id, 'languageId' => $languageId]);
                }
            }

        }
        return $this->render('save', [
            'model' => $model,
            'modelTranslation' => $modelTranslation,
            'selectedLanguage' => Language::findOne($languageId)
        ]);
    }
public function actionSave ( $ id = null , $ languageId = null ) { if ( empty ( $ languageId ) ) { $ languageId = Language :: getCurrent ( ) -> id ; } if ( ! empty ( $ id ) ) { $ model = PaymentMethod :: findOne ( $ id ) ; if ( empty ( $ model ) ) throw new NotFoundHttpException ( ) ; $ modelTranslation = PaymentMethodTranslation :: find ( ) -> where ( [ 'payment_method_id' => $ model -> id , 'language_id' => $ languageId ] ) -> one ( ) ; if ( empty ( $ modelTranslation ) ) { $ modelTranslation = new PaymentMethodTranslation ( ) ; } } else { $ model = new PaymentMethod ( ) ; $ modelTranslation = new PaymentMethodTranslation ( ) ; } if ( \ Yii :: $ app -> request -> isPost ) { if ( $ model -> load ( \ Yii :: $ app -> request -> post ( ) ) ) { $ imageModel = new PaymentImageModel ( ) ; $ imageModel -> imageFile = UploadedFile :: getInstance ( $ model , 'image' ) ; if ( ! empty ( $ imageModel -> imageFile ) ) { $ uploadedImageName = $ imageModel -> upload ( ) ; $ model -> image = $ uploadedImageName ; } } if ( $ modelTranslation -> load ( Yii :: $ app -> request -> post ( ) ) ) { if ( $ modelTranslation -> validate ( ) ) { $ model -> save ( ) ; $ modelTranslation -> payment_method_id = $ model -> id ; $ modelTranslation -> language_id = $ languageId ; $ modelTranslation -> save ( ) ; return $ this -> redirect ( [ 'save' , 'id' => $ model -> id , 'languageId' => $ languageId ] ) ; } } } return $ this -> render ( 'save' , [ 'model' => $ model , 'modelTranslation' => $ modelTranslation , 'selectedLanguage' => Language :: findOne ( $ languageId ) ] ) ; }
Creates a new PaymentMethod model.
If creation is successful, the browser will be redirected to the 'view' page.

@param integer $id
@param integer $languageId
@return mixed
@throws Exception
Creates a new PaymentMethod model . If creation is successful the browser will be redirected to the view page .