Exemple #1
0
 public function actionCheck()
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $request = Yii::$app->request;
     if ($request->isAjax) {
         $post = $request->post();
         $id = $post['id'];
         $app = $post['app'];
         $xml = simplexml_load_string($this->createxml($app, $id), "SimpleXMLElement", LIBXML_NOCDATA);
         $json = json_encode($xml);
         $model = \common\models\Transaction::findOne($id);
         $model->code = $xml->transaction['code'];
         $model->status = $xml->transaction['status'];
         $model->save();
         return $json;
     }
 }
 /**
  * Finds the Transaction model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Transaction the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Transaction::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }