implement mobile devices in reception
This commit is contained in:
parent
34fca82e7d
commit
ac5076534b
@ -12,12 +12,18 @@ namespace mobileapi\controllers;
|
|||||||
use common\components\Helper;
|
use common\components\Helper;
|
||||||
use common\models\Card;
|
use common\models\Card;
|
||||||
use common\models\Ticket;
|
use common\models\Ticket;
|
||||||
|
use mobileapi\manager\ApiManager;
|
||||||
use yii\web\BadRequestHttpException;
|
use yii\web\BadRequestHttpException;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
|
|
||||||
class CustomerApiController extends RestController
|
class ApiController extends RestController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function actionCardPage(){
|
||||||
|
|
||||||
|
$apiManager = new ApiManager();
|
||||||
|
return $apiManager->getCardPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by IntelliJ IDEA.
|
|
||||||
* User: rocho
|
|
||||||
* Date: 2018.08.29.
|
|
||||||
* Time: 21:58
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace mobileapi\controllers;
|
|
||||||
|
|
||||||
use common\models\Customer;
|
|
||||||
use mobileapi\models\PasswordChangeForm;
|
|
||||||
use yii\web\BadRequestHttpException;
|
|
||||||
|
|
||||||
/** @noinspection PhpUnused */
|
|
||||||
|
|
||||||
class UserController extends RestController
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \yii\base\InvalidConfigException
|
|
||||||
* @throws \yii\base\Exception
|
|
||||||
* @throws BadRequestHttpException
|
|
||||||
*/
|
|
||||||
public function actionPasswordChange()
|
|
||||||
{
|
|
||||||
$form = new PasswordChangeForm();
|
|
||||||
$form->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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
30
mobileapi/manager/ApiManager.php
Normal file
30
mobileapi/manager/ApiManager.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
namespace mobileapi\manager;
|
||||||
|
|
||||||
|
use common\models\Card;
|
||||||
|
use Endroid\QrCode\QrCode;
|
||||||
|
|
||||||
|
class ApiManager
|
||||||
|
{
|
||||||
|
public function getCardPage(){
|
||||||
|
$customer = \Yii::$app->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
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user