modules/api/v2/controllers/UserPurchasedSubscriptionsController.php
/**
     * Creates a new UserPurchasedSubscriptions model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new UserPurchasedSubscriptions model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new UserPurchasedSubscriptions model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        $model = new UserPurchasedSubscriptions();
        $model->scenario = 'create_api';
        $postData = \Yii::$app->request->post();
        $userPurchaseSubscriptionData['UserPurchasedSubscriptions'] = $postData;
        $model->user_id = Yii::$app->user->identity->id;
        if ($model->load($userPurchaseSubscriptionData) && $model->validate()) {
            $dateLength = strlen($postData['date_time']);
            $model->date_time = (!empty($dateLength) && $dateLength == 13) ? date('Y-m-d H:i:s', $postData['date_time'] / 1000) : date('Y-m-d H:i:s', $postData['date_time']);
            if ($model->save()) {
                $modelUser = $model->user;
                if (!empty($modelUser) && $modelUser instanceof User) {
                    $modelUser->is_subscribed_user = User::USER_STATUS_ACTIVE;
                    $modelUser->save();
                }
            }
        }
        return $model;
    }
public function actionCreate ( ) { $ model = new UserPurchasedSubscriptions ( ) ; $ model -> scenario = 'create_api' ; $ postData = \ Yii :: $ app -> request -> post ( ) ; $ userPurchaseSubscriptionData [ 'UserPurchasedSubscriptions' ] = $ postData ; $ model -> user_id = Yii :: $ app -> user -> identity -> id ; if ( $ model -> load ( $ userPurchaseSubscriptionData ) && $ model -> validate ( ) ) { $ dateLength = strlen ( $ postData [ 'date_time' ] ) ; $ model -> date_time = ( ! empty ( $ dateLength ) && $ dateLength == 13 ) ? date ( 'Y-m-d H:i:s' , $ postData [ 'date_time' ] / 1000 ) : date ( 'Y-m-d H:i:s' , $ postData [ 'date_time' ] ) ; if ( $ model -> save ( ) ) { $ modelUser = $ model -> user ; if ( ! empty ( $ modelUser ) && $ modelUser instanceof User ) { $ modelUser -> is_subscribed_user = User :: USER_STATUS_ACTIVE ; $ modelUser -> save ( ) ; } } } return $ model ; }
Creates a new UserPurchasedSubscriptions model.
Creates a new UserPurchasedSubscriptions model .