1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace dameter\abstracts\models; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use dameter\abstracts\ManyToManyModel; |
7
|
|
|
use yii\base\NotSupportedException; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class ModelCondition |
11
|
|
|
* @package dameter\abstracts\models |
12
|
|
|
* @author Tõnis Ormisson <[email protected]> |
13
|
|
|
* |
14
|
|
|
* @property integer $condition_id |
15
|
|
|
* @property integer $survey_id |
16
|
|
|
* @property integer $question_id |
17
|
|
|
* @property integer $question_group_id |
18
|
|
|
* @property integer $answer_id |
19
|
|
|
* |
20
|
|
|
* @property BaseSurvey $survey |
21
|
|
|
* @property BaseQuestionGroup $questionGroup |
22
|
|
|
* @property BaseQuestion $question |
23
|
|
|
* @property BaseAnswer $answer |
24
|
|
|
* |
25
|
|
|
* @property Condition $child |
26
|
|
|
*/ |
27
|
|
|
class ModelCondition extends ManyToManyModel |
28
|
|
|
{ |
29
|
|
|
public static $childClass = Condition::class; |
30
|
|
|
|
31
|
|
|
/** {@inheritdoc} */ |
32
|
|
|
public function rules() |
33
|
|
|
{ |
34
|
|
|
return array_merge(parent::rules(), [ |
35
|
|
|
[['survey_id', 'question_group_id', 'question_id', 'answer_id'], 'integer'], |
36
|
|
|
[['survey_id'], 'exist', 'skipOnError' => true, 'targetClass' => BaseSurvey::class, 'targetAttribute' => ['survey_id' => 'survey_id']], |
37
|
|
|
[['question_group_id'], 'exist', 'skipOnError' => true, 'targetClass' => BaseQuestionGroup::class, 'targetAttribute' => ['question_group_id' => 'question_group_id']], |
38
|
|
|
[['question_id'], 'exist', 'skipOnError' => true, 'targetClass' => BaseQuestion::class, 'targetAttribute' => ['question_id' => 'question_id']], |
39
|
|
|
[['answer_id'], 'exist', 'skipOnError' => true, 'targetClass' => BaseAnswer::class, 'targetAttribute' => ['answer_id' => 'answer_id']], |
40
|
|
|
]); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return \yii\db\ActiveQuery |
45
|
|
|
*/ |
46
|
|
|
public function getSurvey() |
47
|
|
|
{ |
48
|
|
|
return $this->hasOne(BaseSurvey::class); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return \yii\db\ActiveQuery |
53
|
|
|
*/ |
54
|
|
|
public function getQuestionGroup() |
55
|
|
|
{ |
56
|
|
|
return $this->hasOne(BaseQuestionGroup::class); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return \yii\db\ActiveQuery |
61
|
|
|
*/ |
62
|
|
|
public function getQuestion() |
63
|
|
|
{ |
64
|
|
|
return $this->hasOne(BaseQuestion::class); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return \yii\db\ActiveQuery |
69
|
|
|
*/ |
70
|
|
|
public function getAnswer() |
71
|
|
|
{ |
72
|
|
|
return $this->hasOne(BaseAnswer::class); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function getParent() |
76
|
|
|
{ |
77
|
|
|
throw new NotSupportedException(); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
|
82
|
|
|
} |