add customer api
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user