fitness-web/mobileapi/manager/ApiManager.php

31 lines
675 B
PHP

<?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
];
}
}