Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 24 |
| MeetingSurveyQuery | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
30.00 | |
0.00% |
0 / 24 |
| __construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 5 |
|||
| userSelector | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 5 |
|||
| meetingSelector | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
| availableForMeeting | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 12 |
|||
| <?php | |
| namespace common\models; | |
| use Yii; | |
| /** | |
| * This is the query model class for table "{{%meeting_survey}}". | |
| */ | |
| class MeetingSurveyQuery extends \yii\db\ActiveQuery implements ISurveyQuery | |
| { use GenericSurveyQuery; | |
| /** | |
| * @inheritdoc | |
| * Set up GenericSurveyQuery | |
| */ | |
| public function __construct($config = []) | |
| { | |
| parent::__construct($config); | |
| $this->subQuery = MeetingSurveyLock::find(); | |
| $this->foreignColumn = '[[meeting_survey_id]]'; | |
| } | |
| protected function userSelector($user_id){ | |
| $participantsSubQuery = Participant::find() | |
| ->select('[[id]]') | |
| ->where(['[[user_id]]' => $user_id]); | |
| return ['IN', '[[participant_id]]', $participantsSubQuery]; | |
| } | |
| protected function meetingSelector($meeting_id){ | |
| return ['meeting_id' => $meeting_id]; | |
| } | |
| /** | |
| * Select only available surveys for meeting | |
| */ | |
| public function availableForMeeting($meeting_id) | |
| { | |
| $this->subQuery->select([$this->foreignColumn]); | |
| $this->subQuery->andWhere($this->meetingSelector($meeting_id)); | |
| if(!$this->subQueryJoined) | |
| { | |
| $class = $this->modelClass; | |
| $tableName = $class::tableName(); | |
| $this->andWhere(['NOT IN', $tableName . '.[[id]]', $this->subQuery]); | |
| $this->subQueryJoined = true; | |
| } | |
| return $this; | |
| } | |
| } |