1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace dameter\abstracts\models; |
4
|
|
|
|
5
|
|
|
use dameter\abstracts\interfaces\Conditionable; |
6
|
|
|
use dameter\abstracts\WithLanguageSettingsModel; |
7
|
|
|
use dameter\abstracts\interfaces\Sortable; |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class BaseAnswer |
12
|
|
|
* @property integer $answer_id |
13
|
|
|
* @property integer $question_id |
14
|
|
|
* @property integer $order |
15
|
|
|
* |
16
|
|
|
* @property BaseQuestion $question |
17
|
|
|
* @property ModelCondition $modelCondition |
18
|
|
|
* @property Condition $condition |
19
|
|
|
* |
20
|
|
|
* @package dameter\abstracts\models |
21
|
|
|
* @author Tõnis Ormisson <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class BaseAnswer extends WithLanguageSettingsModel implements Sortable, Conditionable |
24
|
|
|
{ |
25
|
|
|
|
26
|
|
|
public static $settingsClass = AnswerText::class; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* {@inheritdoc} |
30
|
|
|
*/ |
31
|
|
|
public static function tableName() |
32
|
|
|
{ |
33
|
|
|
return "answer"; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* {@inheritdoc} |
38
|
|
|
*/ |
39
|
|
|
public static function primaryKey() |
40
|
|
|
{ |
41
|
|
|
return ["answer_id"]; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* {@inheritdoc} |
47
|
|
|
*/ |
48
|
|
|
public function rules() |
49
|
|
|
{ |
50
|
|
|
return array_merge(parent::rules(), [ |
51
|
|
|
[['question_id', 'code', 'order'], 'required'], |
52
|
|
|
[['question_id', 'order'], 'integer'], |
53
|
|
|
[['code'], 'string', 'max' => 64], |
54
|
|
|
]); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return \yii\db\ActiveQuery |
59
|
|
|
*/ |
60
|
|
|
public function getQuestion() |
61
|
|
|
{ |
62
|
|
|
return $this->hasOne(BaseQuestion::class); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return Condition |
67
|
|
|
*/ |
68
|
|
|
public function getCondition() |
69
|
|
|
{ |
70
|
|
|
if (!empty($this->modelCondition)) { |
71
|
|
|
return $this->modelCondition->child; |
72
|
|
|
} |
73
|
|
|
return null; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return \yii\db\ActiveQuery |
78
|
|
|
*/ |
79
|
|
|
public function getModelCondition() |
80
|
|
|
{ |
81
|
|
|
return $this->hasOne(ModelCondition::class); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
} |