From ac5076534b908c63618e3bb4e73fa4a031026055 Mon Sep 17 00:00:00 2001 From: Roland Schneider Date: Sat, 19 Feb 2022 15:28:41 +0100 Subject: [PATCH] implement mobile devices in reception --- ...merApiController.php => ApiController.php} | 8 +++- mobileapi/controllers/UserController.php | 47 ------------------- mobileapi/manager/ApiManager.php | 30 ++++++++++++ 3 files changed, 37 insertions(+), 48 deletions(-) rename mobileapi/controllers/{CustomerApiController.php => ApiController.php} (58%) delete mode 100644 mobileapi/controllers/UserController.php create mode 100644 mobileapi/manager/ApiManager.php diff --git a/mobileapi/controllers/CustomerApiController.php b/mobileapi/controllers/ApiController.php similarity index 58% rename from mobileapi/controllers/CustomerApiController.php rename to mobileapi/controllers/ApiController.php index 507cf97..d2889f5 100644 --- a/mobileapi/controllers/CustomerApiController.php +++ b/mobileapi/controllers/ApiController.php @@ -12,12 +12,18 @@ namespace mobileapi\controllers; use common\components\Helper; use common\models\Card; use common\models\Ticket; +use mobileapi\manager\ApiManager; use yii\web\BadRequestHttpException; use yii\web\NotFoundHttpException; -class CustomerApiController extends RestController +class ApiController extends RestController { + public function actionCardPage(){ + + $apiManager = new ApiManager(); + return $apiManager->getCardPage(); + } } diff --git a/mobileapi/controllers/UserController.php b/mobileapi/controllers/UserController.php deleted file mode 100644 index 22503fe..0000000 --- a/mobileapi/controllers/UserController.php +++ /dev/null @@ -1,47 +0,0 @@ -scenario = "default"; - - $form->load(\Yii::$app->request->post(), ''); - - if (!$form->validate()) { - throw new BadRequestHttpException( $form->getErrorSummary(false)[0]); - } - - $customer = Customer::findOne(\Yii::$app->user->id); - - if (!$customer->validatePassword($form->passwordOld)) { - throw new BadRequestHttpException("Jelenlegi jelszó nem egyezik", "2"); - } - - $customer->setPassword($form->password); - - $customer->save(); - } - -} diff --git a/mobileapi/manager/ApiManager.php b/mobileapi/manager/ApiManager.php new file mode 100644 index 0000000..ed291b4 --- /dev/null +++ b/mobileapi/manager/ApiManager.php @@ -0,0 +1,30 @@ +user->getIdentity(); + + if ( $customer == null ){ + throw new \yii\web\NotFoundHttpException(); + } + $card = Card::findOne($customer->id_customer_card); + + if ( $card == null ){ + throw new \yii\web\NotFoundHttpException(); + } + + $qrCode = new QrCode($card->number); + + return [ + 'qrcode' => $qrCode->writeDataUri(), + 'cardNumber' => $card->number, + 'customerName' => $customer->name + ]; + + } +}