Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 59 |
| MeetingSurveyLock | |
0.00% |
0 / 1 |
|
0.00% |
0 / 9 |
342.00 | |
0.00% |
0 / 59 |
| tableName | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| behaviors | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 10 |
|||
| rules | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 7 |
|||
| attributeLabels | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 11 |
|||
| getMeeting | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| getMeetingSurvey | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| getParticipant | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| getSurveyOpinion | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| save | |
0.00% |
0 / 1 |
110.00 | |
0.00% |
0 / 16 |
|||
| <?php | |
| namespace common\models; | |
| use Yii; | |
| use common\models\Meeting; | |
| use yii\behaviors\TimestampBehavior; | |
| /** | |
| * This is the model class for table "{{%meeting_survey_lock}}". | |
| * | |
| * @property string $id | |
| * @property integer $is_host | |
| * @property string $created_at | |
| * @property string $meeting_survey_id | |
| * @property string $meeting_id | |
| * @property string $participant_id | |
| * @property string $survey_opinion_id | |
| * | |
| * @property Meeting $meeting | |
| * @property MeetingSurvey $meetingSurvey | |
| * @property Participant $participant | |
| * @property SurveyOpinion $surveyOpinion | |
| */ | |
| class MeetingSurveyLock extends \yii\db\ActiveRecord | |
| { | |
| /** | |
| * @inheritdoc | |
| */ | |
| public static function tableName() | |
| { | |
| return '{{%meeting_survey_lock}}'; | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function behaviors() | |
| { | |
| return [ | |
| [ | |
| 'class' => TimestampBehavior::className(), | |
| 'attributes' => [ | |
| static::EVENT_BEFORE_INSERT => ['created_at'], | |
| ], | |
| ], | |
| ]; | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function rules() | |
| { | |
| return [ | |
| [['is_host', 'meeting_survey_id', 'meeting_id', 'participant_id', 'survey_opinion_id'], 'required'], | |
| [['is_host', 'meeting_survey_id', 'meeting_id', 'participant_id', 'survey_opinion_id'], 'integer'], | |
| [['meeting_survey_id', 'meeting_id', 'is_host'], 'unique', 'targetAttribute' => ['meeting_survey_id', 'meeting_id', 'is_host'], 'message' => 'The combination of Is Host, Meeting Survey ID and Meeting ID has already been taken.'] | |
| ]; | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function attributeLabels() | |
| { | |
| return [ | |
| 'id' => Yii::t('app', 'ID'), | |
| 'is_host' => Yii::t('app', 'Is Host'), | |
| 'created_at' => Yii::t('app', 'Created At'), | |
| 'meeting_survey_id' => Yii::t('app', 'Meeting Survey ID'), | |
| 'meeting_id' => Yii::t('app', 'Meeting ID'), | |
| 'participant_id' => Yii::t('app', 'Participant ID'), | |
| 'survey_opinion_id' => Yii::t('app', 'Survey Opinion ID'), | |
| ]; | |
| } | |
| /** | |
| * @return \yii\db\ActiveQuery | |
| */ | |
| public function getMeeting() | |
| { | |
| return $this->hasOne(Meeting::className(), ['id' => 'meeting_id']); | |
| } | |
| /** | |
| * @return \yii\db\ActiveQuery | |
| */ | |
| public function getMeetingSurvey() | |
| { | |
| return $this->hasOne(MeetingSurvey::className(), ['id' => 'meeting_survey_id']); | |
| } | |
| /** | |
| * @return \yii\db\ActiveQuery | |
| */ | |
| public function getParticipant() | |
| { | |
| return $this->hasOne(Participant::className(), ['id' => 'participant_id']); | |
| } | |
| /** | |
| * @return \yii\db\ActiveQuery | |
| */ | |
| public function getSurveyOpinion() | |
| { | |
| return $this->hasOne(SurveyOpinion::className(), ['id' => 'survey_opinion_id']); | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function save($runValidation = true, $attributeNames = NULL) | |
| { | |
| if ($this->meeting_id > 0) { | |
| if ($this->is_host === null && $this->participant_id > 0) { | |
| $meeting = Meeting::find()->where(['id' => $this->meeting_id])->one(); | |
| if (count($meeting) == 1) { | |
| $this->is_host = ($meeting->host_participant_id == $this->participant_id) ? 1 : 0; | |
| } | |
| } else if ($this->participant_id === null && $this->is_host >= 0) { | |
| $meeting = Meeting::find()->where(['id' => $this->meeting_id])->one(); | |
| if (count($meeting) == 1) { | |
| $this->participant_id = $meeting->is_host == 1 ? $meeting->host_participant_id : $host_participant_id->guest_participant_id; | |
| } | |
| } | |
| } | |
| parent::save($runValidation, $attributeNames); | |
| } | |
| } |