fitness-web/frontend/models/ReceptionForm.php

59 lines
983 B
PHP

<?php
namespace frontend\models;
use Yii;
use yii\base\Model;
use common\models\Card;
use common\models\Customer;
use common\models\Ticket;
/**
* ContactForm is the model behind the contact form.
*/
class ReceptionForm extends Model
{
public $number;
public $card;
public $customer;
public $tickets;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['number'], 'required'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'verifyCode' => 'Verification Code',
];
}
public function readCard(){
$this->card = Card::findOne(['number' => $this->number]);
if ( $this->card != null ){
$this->customer = $this->card->customer;
$this->readValidTickets();
}
}
public function readValidTickets(){
$this->tickets = Ticket::readActive($this->card);
}
}