implement registration
This commit is contained in:
@@ -9,14 +9,16 @@ use yii\helpers\ArrayHelper;
|
||||
/**
|
||||
* This is the model class for table "event".
|
||||
*
|
||||
// * @property integer $id
|
||||
* @property integer $id
|
||||
* @property integer $start
|
||||
* @property integer $end
|
||||
* @property integer $id_room
|
||||
* @property integer $id_trainer
|
||||
* @property integer $id_event_type
|
||||
* @property integer $seat_count
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property \common\models\EventType eventType
|
||||
*/
|
||||
class Event extends \yii\db\ActiveRecord
|
||||
{
|
||||
@@ -73,6 +75,9 @@ class Event extends \yii\db\ActiveRecord
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function afterFind()
|
||||
{
|
||||
parent::afterFind(); // TODO: Change the autogenerated stub
|
||||
@@ -104,8 +109,31 @@ class Event extends \yii\db\ActiveRecord
|
||||
return $this->hasOne(Trainer::className(),['id' => 'id_trainer']);
|
||||
}
|
||||
|
||||
public function getRoom(){
|
||||
/**
|
||||
* @return Room|\yii\db\ActiveQuery
|
||||
*/
|
||||
public function getRoom() {
|
||||
return $this->hasOne(Room::className(),['id' => 'id_room']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \common\models\EventRegistration[]|\yii\db\ActiveQuery
|
||||
*/
|
||||
public function getEventRegistrations(){
|
||||
return $this->hasMany(EventRegistration::className(),['id_event' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \common\models\EventRegistration[]|\yii\db\ActiveQuery
|
||||
*/
|
||||
public function getEventRegistrationCount(){
|
||||
return sizeof($this->getEventRegistrations());
|
||||
}
|
||||
|
||||
public function hasFreeSeats(){
|
||||
$registrationCount = $this->getEventRegistrations() ;
|
||||
|
||||
return $registrationCount < $this->seat_count ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user