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 $question_id |
16
|
|
|
* @property integer $question_group_id |
17
|
|
|
* @property integer $answer_id |
18
|
|
|
* |
19
|
|
|
* @property BaseQuestionGroup $questionGroup |
20
|
|
|
* @property BaseQuestion $question |
21
|
|
|
* @property BaseAnswer $answer |
22
|
|
|
* |
23
|
|
|
* @property Condition $child |
24
|
|
|
*/ |
25
|
|
|
class ModelCondition extends ManyToManyModel |
26
|
|
|
{ |
27
|
|
|
public static $childClass = Condition::class; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* {@inheritdoc} |
31
|
|
|
*/ |
32
|
|
|
public static function tableName() |
33
|
|
|
{ |
34
|
|
|
return "model_condition"; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
|
|
public static function primaryKey() |
41
|
|
|
{ |
42
|
|
|
return ["model_condition_id"]; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* {@inheritdoc} |
47
|
|
|
*/ |
48
|
|
|
public static function primaryKeySingle() |
49
|
|
|
{ |
50
|
|
|
return "model_condition_id"; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** {@inheritdoc} */ |
54
|
|
|
public function rules() |
55
|
|
|
{ |
56
|
|
|
return array_merge(parent::rules(), [ |
57
|
|
|
[['question_group_id', 'question_id', 'answer_id'], 'integer'], |
58
|
|
|
[['question_group_id'], 'exist', 'skipOnError' => true, 'targetClass' => BaseQuestionGroup::class, 'targetAttribute' => ['question_group_id' => 'question_group_id']], |
59
|
|
|
[['question_id'], 'exist', 'skipOnError' => true, 'targetClass' => BaseQuestion::class, 'targetAttribute' => ['question_id' => 'question_id']], |
60
|
|
|
[['answer_id'], 'exist', 'skipOnError' => true, 'targetClass' => BaseAnswer::class, 'targetAttribute' => ['answer_id' => 'answer_id']], |
61
|
|
|
]); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return \yii\db\ActiveQuery |
66
|
|
|
*/ |
67
|
|
|
public function getQuestionGroup() |
68
|
|
|
{ |
69
|
|
|
return $this->hasOne(BaseQuestionGroup::class); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return \yii\db\ActiveQuery |
74
|
|
|
*/ |
75
|
|
|
public function getQuestion() |
76
|
|
|
{ |
77
|
|
|
return $this->hasOne(BaseQuestion::class); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return \yii\db\ActiveQuery |
82
|
|
|
*/ |
83
|
|
|
public function getAnswer() |
84
|
|
|
{ |
85
|
|
|
return $this->hasOne(BaseAnswer::class); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function getParent() |
89
|
|
|
{ |
90
|
|
|
throw new NotSupportedException(); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
|
95
|
|
|
} |