Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 9
CRAP
0.00% covered (danger)
0.00%
0 / 45
AccompanyingEventSurvey
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 9
90.00
0.00% covered (danger)
0.00%
0 / 45
 tableName
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 3
 behaviors
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 10
 rules
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 9
 attributeLabels
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 8
 getAccompanyingEvent
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 3
 getSurvey
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 3
 getAccompanyingEventSurveyLocks
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 3
 getParticipants
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 3
 find
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 3
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
/**
 * This is the model class for table "{{%accompanying_event_survey}}".
 *
 * @property string $id
 * @property string $created_at
 * @property string $survey_id
 * @property string $accompanying_event_id
 *
 * @property AccompanyingEvent $accompanyingEvent
 * @property Survey $survey
 * @property AccompanyingEventSurveyLock[] $accompanyingEventSurveyLocks
 * @property Participant[] $participants
 */
class AccompanyingEventSurvey extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%accompanying_event_survey}}';
    }
    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
                'attributes' => [
                    static::EVENT_BEFORE_INSERT => ['created_at'],
                ],
            ],
        ];
    }
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['survey_id', 'accompanying_event_id'], 'required'],
            [['survey_id', 'accompanying_event_id'], 'integer'],
            [['survey_id', 'accompanying_event_id'], 'unique', 'targetAttribute' => ['survey_id', 'accompanying_event_id'], 'message' => 'The combination of Survey ID and Accompanying Event ID has already been taken.'],
            [['accompanying_event_id'], 'exist', 'skipOnError' => true, 'targetClass' => AccompanyingEvent::className(), 'targetAttribute' => ['accompanying_event_id' => 'id']],
            [['survey_id'], 'exist', 'skipOnError' => true, 'targetClass' => Survey::className(), 'targetAttribute' => ['survey_id' => 'id']],
        ];
    }
    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'created_at' => Yii::t('app', 'Created At'),
            'survey_id' => Yii::t('app', 'Survey ID'),
            'accompanying_event_id' => Yii::t('app', 'Accompanying Event ID'),
        ];
    }
    /**
     * @return \yii\db\ActiveQuery
     */
    public function getAccompanyingEvent()
    {
        return $this->hasOne(AccompanyingEvent::className(), ['id' => 'accompanying_event_id']);
    }
    /**
     * @return \yii\db\ActiveQuery
     */
    public function getSurvey()
    {
        return $this->hasOne(Survey::className(), ['id' => 'survey_id']);
    }
    /**
     * @return \yii\db\ActiveQuery
     */
    public function getAccompanyingEventSurveyLocks()
    {
        return $this->hasMany(AccompanyingEventSurveyLock::className(), ['accompanying_event_survey_id' => 'id']);
    }
    /**
     * @return \yii\db\ActiveQuery
     */
    public function getParticipants()
    {
        return $this->hasMany(Participant::className(), ['id' => 'participant_id'])->viaTable('{{%accompanying_event_survey_lock}}', ['accompanying_event_survey_id' => 'id']);
    }
    /**
     * @inheritdoc
     * @return AccompanyingEventSurveyQuery
     */
    public static function find()
    {
        return new AccompanyingEventSurveyQuery(get_called_class());
    }
}