Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 17 |
| UserResource | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
20.00 | |
0.00% |
0 / 17 |
| fields | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 5 |
|||
| getLinks | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 6 |
|||
| getParticipant | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| getSupervisor | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| <?php | |
| namespace api\modules\v1\models; | |
| use common\models\User; | |
| 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\User`. | |
| */ | |
| class UserResource extends User implements Linkable | |
| { | |
| // filter out some fields, best used when you want to inherit the parent implementation | |
| // and blacklist some sensitive fields. | |
| public function fields() | |
| { | |
| $fields = parent::fields(); | |
| // remove fields that contain sensitive information | |
| unset($fields['auth_key'], $fields['password_hash'], $fields['password_reset_token'], $fields['email_confirm_token']); | |
| return $fields; | |
| } | |
| public function getLinks() | |
| { | |
| return [ | |
| Link::REL_SELF => Url::to(['user/view', 'id' => $this->id], true), | |
| 'index' => Url::to(['users/index'], true), | |
| ]; | |
| } | |
| /** | |
| * @return \yii\db\ActiveQuery | |
| */ | |
| public function getParticipant() | |
| { | |
| return $this->hasOne(ParticipantResource::className(), ['user_id' => 'id']); | |
| } | |
| /** | |
| * @return \yii\db\ActiveQuery | |
| */ | |
| public function getSupervisor() | |
| { | |
| return $this->hasOne(SupervisorResource::className(), ['user_id' => 'id']); | |
| } | |
| } |