Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 29 |
| EventQuery | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
72.00 | |
0.00% |
0 / 29 |
| getNowDate | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| getNowDateTime | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| active | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 7 |
|||
| canRegister | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
| canMakeMeeting | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
| <?php | |
| namespace common\models; | |
| use Yii; | |
| /** | |
| * This is the query model class for table "{{%event}}". | |
| */ | |
| class EventQuery extends \yii\db\ActiveQuery | |
| { | |
| protected function getNowDate() | |
| { | |
| return Yii::$app->getFormatter()->asDate(time(), 'php:Y-m-d'); | |
| } | |
| protected function getNowDateTime() | |
| { | |
| return Yii::$app->getFormatter()->asDate(time(), 'php:Y-m-d H:i:s'); | |
| } | |
| public function active($isActive = true) | |
| { | |
| if($isActive){ | |
| return $this->andWhere(['is_enabled' => Event::STATUS_ACTIVE]); | |
| }else{ | |
| return $this->andWhere(['is_enabled' => Event::STATUS_DISABLED]); | |
| } | |
| } | |
| public function canRegister($can = true) | |
| { | |
| $now = $this->getNowDateTime(); | |
| if($can){ | |
| return $this->andWhere(['AND', ['OR', 'registration_from IS NULL', ['<=', 'registration_from', $now]], ['OR', 'registration_to IS NULL', ['>=', 'registration_to', $now]]]); | |
| }else{ | |
| return $this->andWhere(['OR', ['>', 'registration_from', $now], ['<', 'registration_to', $now]]); | |
| } | |
| } | |
| public function canMakeMeeting($can = true) | |
| { | |
| $now = $this->getNowDateTime(); | |
| if($can){ | |
| return $this->andWhere(['AND', ['<=', 'make_meeting_from', $now], ['>=', 'make_meeting_to', $now]]); | |
| }else{ | |
| return $this->andWhere(['OR', ['>', 'make_meeting_from', $now], ['<', 'make_meeting_to', $now]]); | |
| } | |
| } | |
| } |