add customer api
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace common\models;
|
||||
use common\components\Helper;
|
||||
use yii\base\Model;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
@@ -9,7 +10,7 @@ use common\components\Helper;
|
||||
* Time: 6:14
|
||||
*/
|
||||
|
||||
class CardEventRegistrationForm extends \yii\base\Model
|
||||
class CardEventRegistrationForm extends Model
|
||||
{
|
||||
public $card_number;
|
||||
public $event_id;
|
||||
@@ -41,4 +42,4 @@ class CardEventRegistrationForm extends \yii\base\Model
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,13 +211,13 @@ class Customer extends BaseFitnessActiveRecord implements IdentityInterface
|
||||
/**
|
||||
* Finds an identity by the given ID.
|
||||
* @param string|integer $id the ID to be looked for
|
||||
* @return void the identity object that matches the given ID.
|
||||
* @return Customer
|
||||
* Null should be returned if such an identity cannot be found
|
||||
* or the identity is not in an active state (disabled, deleted, etc.)
|
||||
*/
|
||||
public static function findIdentity($id)
|
||||
{
|
||||
Customer::findOne($id);
|
||||
return self::findOne(['email' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -111,18 +111,18 @@ class Event extends \yii\db\ActiveRecord
|
||||
}
|
||||
|
||||
public function getEventType(){
|
||||
return $this->hasOne(EventType::className(),['id' => 'id_event_type']);
|
||||
return $this->hasOne($this->getEventTypeClass(),['id' => 'id_event_type']);
|
||||
}
|
||||
|
||||
public function getTrainer(){
|
||||
return $this->hasOne(Trainer::className(),['id' => 'id_trainer']);
|
||||
return $this->hasOne($this->getTrainerClass(),['id' => 'id_trainer']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Room|\yii\db\ActiveQuery
|
||||
*/
|
||||
public function getRoom() {
|
||||
return $this->hasOne(Room::className(),['id' => 'id_room']);
|
||||
return $this->hasOne($this->getRoomClass(),['id' => 'id_room']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,16 +139,24 @@ class Event extends \yii\db\ActiveRecord
|
||||
return $this->hasMany(EventRegistration::className(),['id_event' => 'id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \common\models\EventRegistration[]|\yii\db\ActiveQuery
|
||||
*/
|
||||
public function getActiveEventRegistrations(){
|
||||
return $this->hasMany(EventRegistration::className(),['id_event' => 'id'])->andWhere(
|
||||
[
|
||||
'event_registration.canceled_at' => null,
|
||||
'event_registration.deleted_at' => null,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \common\models\EventRegistration[]|\yii\db\ActiveQuery
|
||||
*/
|
||||
public function getEventRegistrationCount(){
|
||||
return sizeof($this->getEventRegistrations()
|
||||
->andWhere( [
|
||||
'canceled_at' => null,
|
||||
'deleted_at' => null,
|
||||
])
|
||||
->all());
|
||||
return sizeof($this->getActiveEventRegistrations()->all());
|
||||
}
|
||||
|
||||
public function getOpenSeatCount(){
|
||||
@@ -183,4 +191,16 @@ class Event extends \yii\db\ActiveRecord
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected function getTrainerClass(){
|
||||
return Trainer::class;
|
||||
}
|
||||
protected function getEventTypeClass(){
|
||||
return EventType::class;
|
||||
}
|
||||
|
||||
protected function getRoomClass(){
|
||||
return Room::class;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,4 +65,14 @@ class EventRegistration extends \yii\db\ActiveRecord
|
||||
],
|
||||
parent::behaviors());
|
||||
}
|
||||
|
||||
|
||||
public function getEvent(){
|
||||
return $this->hasOne(Event::class,['id' => 'id_event']);
|
||||
}
|
||||
|
||||
public function getCustomer(){
|
||||
return $this->hasOne(Customer::class,['id' => 'id_customer']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user