1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace andmemasin\surveybasemodels; |
4
|
|
|
|
5
|
|
|
use Yii; |
6
|
|
|
use andmemasin\myabstract\MyActiveRecord; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* This is the model class for table "rating". |
10
|
|
|
* |
11
|
|
|
* @property integer $rating_id |
12
|
|
|
* @property integer $respondent_id |
13
|
|
|
* @property integer $survey_id |
14
|
|
|
* @property integer $sample_id |
15
|
|
|
* @property integer $value |
16
|
|
|
* @property string $comment |
17
|
|
|
* |
18
|
|
|
* @property Respondent $respondent |
19
|
|
|
*/ |
20
|
|
|
class Rating extends MyActiveRecord |
21
|
|
|
{ |
22
|
|
|
public $initRespondent; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
|
|
public static function tableName() |
28
|
|
|
{ |
29
|
|
|
return 'rating'; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* {@inheritdoc} |
34
|
|
|
*/ |
35
|
|
|
public static function modelName() |
36
|
|
|
{ |
37
|
|
|
return Yii::t('app','Rating'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* {@inheritdoc} |
44
|
|
|
*/ |
45
|
|
|
public function rules() |
46
|
|
|
{ |
47
|
|
|
return array_merge([ |
48
|
|
|
[['respondent_id', 'survey_id', 'sample_id', 'value'], 'required'], |
49
|
|
|
[['respondent_id', 'survey_id', 'sample_id', 'value'], 'integer'], |
50
|
|
|
[['comment'], 'string'], |
51
|
|
|
[['respondent_id'], 'exist', 'skipOnError' => true, 'targetClass' => Respondent::class, 'targetAttribute' => ['respondent_id' => 'respondent_id']], |
52
|
|
|
], parent::rules()); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* {@inheritdoc} |
57
|
|
|
*/ |
58
|
|
|
public function attributeLabels() |
59
|
|
|
{ |
60
|
|
|
return [ |
61
|
|
|
'rating_id' => Yii::t('app', 'Rating ID'), |
62
|
|
|
'respondent_id' => Yii::t('app', 'Respondent'), |
63
|
|
|
'survey_id' => Yii::t('app', 'Survey'), |
64
|
|
|
'sample_id' => Yii::t('app', 'Sample'), |
65
|
|
|
'value' => Yii::t('app', 'Rating value'), |
66
|
|
|
'comment' => Yii::t('app', 'Comment'), |
67
|
|
|
]; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return \yii\db\ActiveQuery |
72
|
|
|
*/ |
73
|
|
|
public function getRespondent() |
74
|
|
|
{ |
75
|
|
|
return $this->hasOne(Respondent::class, ['respondent_id' => 'respondent_id']); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
} |
79
|
|
|
|