modules/api/v2/controllers/UserBankDetailsController.php
/**
     * Updates an existing UserBankDetails model.
     * If update is successful, the browser will be redirected to the 'view' page.
     * @param integer $id
     * @return mixed
     * @throws NotFoundHttpException if the model cannot be found
     */
Updates an existing UserBankDetails model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed
@throws NotFoundHttpException if the model cannot be found
Updates an existing UserBankDetails model . If update is successful the browser will be redirected to the ' view ' page . @param integer $id @return mixed @throws NotFoundHttpException if the model cannot be found
public function actionUpdate($id)
    {
        $model = UserBankDetails::find()->where(['id' => $id])->one();
        if (!$model instanceof UserBankDetails || $model->user_id != Yii::$app->user->identity->id) {
            throw new NotFoundHttpException('User bank detail doesn\'t exist.');
        }
        $model->scenario = UserBankDetails::SCENARIO_UPDATE;
        $postData = \Yii::$app->request->post();
        $data['UserBankDetails'] = $postData;
        $model->user_id = Yii::$app->user->identity->id;
        if (!empty($data['UserBankDetails']) && !empty($data['UserBankDetails']['payment_type']) && strtolower($data['UserBankDetails']['payment_type']) == UserBankDetails::PAYMENT_TYPE_PAYPAL) {
            $model->scenario = UserBankDetails::PAYMENT_TYPE_PAYPAL;
        } elseif (!empty($data['UserBankDetails']) && !empty($data['UserBankDetails']['payment_type']) && strtolower($data['UserBankDetails']['payment_type']) == UserBankDetails::PAYMENT_TYPE_BANK) {
            $model->scenario = UserBankDetails::PAYMENT_TYPE_BANK;
        }
        if ($model->load($data) && $model->validate()) {
            $model->save();
        }
        return $model;
    }
public function actionUpdate ( $ id ) { $ model = UserBankDetails :: find ( ) -> where ( [ 'id' => $ id ] ) -> one ( ) ; if ( ! $ model instanceof UserBankDetails || $ model -> user_id != Yii :: $ app -> user -> identity -> id ) { throw new NotFoundHttpException ( 'User bank detail doesn\'t exist.' ) ; } $ model -> scenario = UserBankDetails :: SCENARIO_UPDATE ; $ postData = \ Yii :: $ app -> request -> post ( ) ; $ data [ 'UserBankDetails' ] = $ postData ; $ model -> user_id = Yii :: $ app -> user -> identity -> id ; if ( ! empty ( $ data [ 'UserBankDetails' ] ) && ! empty ( $ data [ 'UserBankDetails' ] [ 'payment_type' ] ) && strtolower ( $ data [ 'UserBankDetails' ] [ 'payment_type' ] ) == UserBankDetails :: PAYMENT_TYPE_PAYPAL ) { $ model -> scenario = UserBankDetails :: PAYMENT_TYPE_PAYPAL ; } elseif ( ! empty ( $ data [ 'UserBankDetails' ] ) && ! empty ( $ data [ 'UserBankDetails' ] [ 'payment_type' ] ) && strtolower ( $ data [ 'UserBankDetails' ] [ 'payment_type' ] ) == UserBankDetails :: PAYMENT_TYPE_BANK ) { $ model -> scenario = UserBankDetails :: PAYMENT_TYPE_BANK ; } if ( $ model -> load ( $ data ) && $ model -> validate ( ) ) { $ model -> save ( ) ; } return $ model ; }
Updates an existing UserBankDetails model.
Updates an existing UserBankDetails model .