255] ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => Yii::t('event-type', 'ID'), 'name' => Yii::t('event-type', 'Name'), 'created_at' => Yii::t('event-type', 'Created At'), 'updated_at' => Yii::t('event-type', 'Updated At'), ]; } public function behaviors() { return ArrayHelper::merge( [ [ 'class' => TimestampBehavior::className(), 'value' => function(){ return date('Y-m-d H:i:s' ); } ] ], parent::behaviors()); } public function asOptions(){ $items = ArrayHelper::map(EventType::find()->all(),'id','name'); return ArrayHelper::merge(['' => \Yii::t('event-type','All')],$items); } public static function eventTypeOptions($all = false, $emptyString = false){ $items = ArrayHelper::map(EventType::find()->all(),'id','name'); $extra = []; if ( $all ) { $extra = ['' => \Yii::t('event-type','All')]; } if ( $emptyString ) { $extra = ['' => '' ]; } return ArrayHelper::merge($extra,$items); } /** * Find the first ticket, which allows this event type * @param \common\models\Ticket[] $tickets the list of active tickets * @return Ticket|null */ public function findTicketAllowingEventType($tickets){ if (!isset($tickets)){ return null; } if ( sizeof($tickets) == 0 ){ return null; } // TODO: implement bossiness logic to select ticket return $tickets[0]; } }