bug fixing
This commit is contained in:
@@ -20,6 +20,7 @@ use yii\helpers\ArrayHelper;
|
||||
* @property integer $end
|
||||
* @property integer $id_room
|
||||
* @property integer $id_trainer
|
||||
* @property integer $id_user
|
||||
* @property integer $id_event_type
|
||||
* @property integer $seat_count
|
||||
* @property string $created_at
|
||||
@@ -40,6 +41,7 @@ class Event extends ActiveRecord
|
||||
public $timestampStart;
|
||||
public $timestampEnd;
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@@ -58,6 +60,7 @@ class Event extends ActiveRecord
|
||||
[['endDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'end' , 'timeZone' => 'UTC'],
|
||||
[['id_trainer','id_room', 'id_event_type','seat_count'], 'required'],
|
||||
[['id_trainer','id_room', 'id_event_type','seat_count'], 'integer'],
|
||||
[['id_trainer','id_room', 'id_event_type','seat_count'], 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -155,8 +158,6 @@ class Event extends ActiveRecord
|
||||
return $this->hasMany($this->getEquipmentTypeAssignmentsClass(),['id_event' => 'id']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return EventRegistration[]|ActiveQuery
|
||||
*/
|
||||
@@ -174,7 +175,9 @@ class Event extends ActiveRecord
|
||||
* @return integer
|
||||
*/
|
||||
public function getEventRegistrationCount(){
|
||||
return count($this->getActiveEventRegistrations()->all());
|
||||
$registrations = EventRegistration::find()->andWhere(['id_event' => $this->id])->all();
|
||||
$activeRegistrations = EventRegistration::filterActive($registrations);
|
||||
return count($activeRegistrations);
|
||||
}
|
||||
|
||||
protected function getEquipmentTypeAssignmentsClass()
|
||||
@@ -188,7 +191,9 @@ class Event extends ActiveRecord
|
||||
}
|
||||
|
||||
public function hasFreeSeats(){
|
||||
$registrationCount = count($this->eventRegistrations) ;
|
||||
$registrations = EventRegistration::find()->andWhere(['id_event' => $this->id])->all();
|
||||
$activeRegistrations = EventRegistration::filterActive($registrations);
|
||||
$registrationCount = count($activeRegistrations) ;
|
||||
|
||||
$seatCount = $this->seat_count;
|
||||
if ( !isset($seatCount ) || $seatCount === 0){
|
||||
|
||||
Reference in New Issue
Block a user