modules/api/v2/controllers/UserBankDetailsController.php
/**
     * Creates a new UserBankDetails model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new UserBankDetails model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new UserBankDetails model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        $model = new UserBankDetails();
        $postData = \Yii::$app->request->post();
        $userBankDetailData['UserBankDetails'] = $postData;
        $model->user_id = Yii::$app->user->identity->id;
        $oldData = UserBankDetails::find()->where(['user_id' => Yii::$app->user->identity->id])->one();
        if (!empty($oldData) && $oldData instanceof UserBankDetails) {
            $oldData->delete();
        }
        if (!empty($userBankDetailData['UserBankDetails']) && !empty($userBankDetailData['UserBankDetails']['payment_type']) && strtolower($userBankDetailData['UserBankDetails']['payment_type']) == UserBankDetails::PAYMENT_TYPE_PAYPAL) {
            $model->scenario = UserBankDetails::PAYMENT_TYPE_PAYPAL;
        } elseif (!empty($userBankDetailData['UserBankDetails']) && !empty($userBankDetailData['UserBankDetails']['payment_type']) && strtolower($userBankDetailData['UserBankDetails']['payment_type']) == UserBankDetails::PAYMENT_TYPE_BANK) {
            $model->scenario = UserBankDetails::PAYMENT_TYPE_BANK;
        }
        if ($model->load($userBankDetailData) && $model->validate()) {
            $model->save();
        }
        return $model;
    }
public function actionCreate ( ) { $ model = new UserBankDetails ( ) ; $ postData = \ Yii :: $ app -> request -> post ( ) ; $ userBankDetailData [ 'UserBankDetails' ] = $ postData ; $ model -> user_id = Yii :: $ app -> user -> identity -> id ; $ oldData = UserBankDetails :: find ( ) -> where ( [ 'user_id' => Yii :: $ app -> user -> identity -> id ] ) -> one ( ) ; if ( ! empty ( $ oldData ) && $ oldData instanceof UserBankDetails ) { $ oldData -> delete ( ) ; } if ( ! empty ( $ userBankDetailData [ 'UserBankDetails' ] ) && ! empty ( $ userBankDetailData [ 'UserBankDetails' ] [ 'payment_type' ] ) && strtolower ( $ userBankDetailData [ 'UserBankDetails' ] [ 'payment_type' ] ) == UserBankDetails :: PAYMENT_TYPE_PAYPAL ) { $ model -> scenario = UserBankDetails :: PAYMENT_TYPE_PAYPAL ; } elseif ( ! empty ( $ userBankDetailData [ 'UserBankDetails' ] ) && ! empty ( $ userBankDetailData [ 'UserBankDetails' ] [ 'payment_type' ] ) && strtolower ( $ userBankDetailData [ 'UserBankDetails' ] [ 'payment_type' ] ) == UserBankDetails :: PAYMENT_TYPE_BANK ) { $ model -> scenario = UserBankDetails :: PAYMENT_TYPE_BANK ; } if ( $ model -> load ( $ userBankDetailData ) && $ model -> validate ( ) ) { $ model -> save ( ) ; } return $ model ; }
Creates a new UserBankDetails model.
Creates a new UserBankDetails model .
//$model->scenario = UserBankDetails::SCENARIO_CREATE; // Delete Old record start // Delete Old record end