implement registration in backend
This commit is contained in:
@@ -18,7 +18,10 @@ use yii\helpers\ArrayHelper;
|
||||
* @property integer $seat_count
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property \common\models\EventType eventType
|
||||
* @property \common\models\EventType $eventType
|
||||
* @property \common\models\Trainer $trainer
|
||||
* @property \common\models\Room $room
|
||||
* @property \common\models\EventRegistration[] $eventRegistrations
|
||||
*/
|
||||
class Event extends \yii\db\ActiveRecord
|
||||
{
|
||||
@@ -45,7 +48,8 @@ class Event extends \yii\db\ActiveRecord
|
||||
return [
|
||||
[['startDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'start', 'timeZone' => 'UTC'],
|
||||
[['endDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'end' , 'timeZone' => 'UTC'],
|
||||
[['id_trainer','id_room', 'id_event_type'], 'required'],
|
||||
[['id_trainer','id_room', 'id_event_type','seat_count'], 'required'],
|
||||
[['id_trainer','id_room', 'id_event_type','seat_count'], 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -72,6 +76,7 @@ class Event extends \yii\db\ActiveRecord
|
||||
'startDateString' => Yii::t('event', 'Start'),
|
||||
'endDateString' => Yii::t('event', 'End'),
|
||||
'status' => Yii::t('event', 'Status'),
|
||||
'seat_count' => Yii::t('event', 'Seat Count'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -127,13 +132,18 @@ class Event extends \yii\db\ActiveRecord
|
||||
* @return \common\models\EventRegistration[]|\yii\db\ActiveQuery
|
||||
*/
|
||||
public function getEventRegistrationCount(){
|
||||
return sizeof($this->getEventRegistrations());
|
||||
return sizeof($this->eventRegistrations);
|
||||
}
|
||||
|
||||
public function hasFreeSeats(){
|
||||
$registrationCount = $this->getEventRegistrations() ;
|
||||
$registrationCount = sizeof($this->eventRegistrations) ;
|
||||
|
||||
return $registrationCount < $this->seat_count ;
|
||||
$seatCount = $this->seat_count;
|
||||
if ( !isset($seatCount ) || $seatCount == 0){
|
||||
$seatCount = PHP_INT_MAX;
|
||||
}
|
||||
|
||||
return $registrationCount < $seatCount ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user