common/modules/api_v1/v1/controllers/ResellerController.php
/**
     * Sets voucher status to SUSPENDED
     *
     * @return mixed
     */
Sets voucher status to SUSPENDED
@return mixed
Sets voucher status to SUSPENDED @return mixed
public function actionSuspendVoucher()
    {
        $code = Yii::$app->request->post('voucher', null);
        $issuer = Yii::$app->user->identity;
        if (($voucher = Voucher::findByCodeAndIssuer($code, $issuer)) != null) {
            if ($voucher->status != Voucher::STATUS_USED) {
                $voucher->setScenario(Voucher::SCENARIO_UPDATE);
                $voucher->status = Voucher::STATUS_SUSPENDED;
                if ($voucher->save()) {
                    return [
                        'success' => true,
                        'voucher' => $voucher
                    ];
                } else {
                    return [
                        'success' => false,
                        'message' => 'Failed to suspend voucher.',
                        'errors' => $voucher->getErrors()
                    ];
                }
            } else {
                return [
                    'success' => false,
                    'message' => 'Voucher is already used and can\'t be suspended.'
                ];
            }
        } else {
            return [
                'success' => false,
                'message' => 'Voucher not found.'
            ];
        }
    }
public function actionSuspendVoucher ( ) { $ code = Yii :: $ app -> request -> post ( 'voucher' , null ) ; $ issuer = Yii :: $ app -> user -> identity ; if ( ( $ voucher = Voucher :: findByCodeAndIssuer ( $ code , $ issuer ) ) != null ) { if ( $ voucher -> status != Voucher :: STATUS_USED ) { $ voucher -> setScenario ( Voucher :: SCENARIO_UPDATE ) ; $ voucher -> status = Voucher :: STATUS_SUSPENDED ; if ( $ voucher -> save ( ) ) { return [ 'success' => true , 'voucher' => $ voucher ] ; } else { return [ 'success' => false , 'message' => 'Failed to suspend voucher.' , 'errors' => $ voucher -> getErrors ( ) ] ; } } else { return [ 'success' => false , 'message' => 'Voucher is already used and can\'t be suspended.' ] ; } } else { return [ 'success' => false , 'message' => 'Voucher not found.' ] ; } }
Sets voucher status to SUSPENDED
 @return mixed
Sets voucher status to SUSPENDED @return mixed