Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 22 |
| EventResource | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
20.00 | |
0.00% |
0 / 22 |
| getLinks | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 6 |
|||
| getOrganizations | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| getEventSpans | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| getParticipants | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 10 |
|||
| <?php | |
| namespace api\modules\v1\models; | |
| use common\models\Event; | |
| use yii\base\Model; | |
| use yii\web\Link; // represents a link object as defined in JSON Hypermedia API Language. | |
| use yii\web\Linkable; | |
| use yii\helpers\Url; | |
| /** | |
| * This is the resource class for model `common\models\Event`. | |
| */ | |
| class EventResource extends Event implements Linkable | |
| { | |
| public function getLinks() | |
| { | |
| return [ | |
| Link::REL_SELF => Url::to(['event/view', 'id' => $this->id], true), | |
| 'index' => Url::to(['event/index'], true), | |
| ]; | |
| } | |
| /** | |
| * @return \yii\db\ActiveQuery | |
| */ | |
| public function getOrganizations() | |
| { | |
| return $this->hasMany(OrganizationResource::className(), ['event_id' => 'id']); | |
| } | |
| /** | |
| * @return \yii\db\ActiveQuery | |
| */ | |
| public function getEventSpans() | |
| { | |
| return $this->hasMany(EventSpanResource::className(), ['event_id' => 'id']); | |
| } | |
| /** | |
| * @return \yii\db\ActiveQuery | |
| */ | |
| public function getParticipants() | |
| { | |
| $eventSpans = $this->getEventSpans()->select('id'); | |
| $query = ParticipantResource::find() | |
| ->from(ParticipantResource::tableName() . ' p') | |
| ->innerJoin('{{%participant_event_span}} pes', | |
| ['AND', 'pes.[[participant_id]] = p.[[id]]', | |
| ['IN', 'pes.[[event_span_id]]', $eventSpans]]); | |
| $query->multiple = true; | |
| return $query; | |
| } | |
| } |