add customer api

This commit is contained in:
2019-10-08 22:33:25 +02:00
committed by Roland Schneider
parent 9aee187d11
commit 1300bfc752
33 changed files with 1164 additions and 246 deletions

View File

@@ -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;
}
}