1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace roaresearch\yii2\formgenerator\models; |
4
|
|
|
|
5
|
|
|
use yii\db\ActiveQuery; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Model class for table `{{%formgenerator_solicitude}}` |
9
|
|
|
* |
10
|
|
|
* @property int $id |
11
|
|
|
* @property int $form_id |
12
|
|
|
* @property string $label |
13
|
|
|
* @property int $created_by |
14
|
|
|
* @property string $created_at |
15
|
|
|
* @property int $updated_by |
16
|
|
|
* @property string $updated_at |
17
|
|
|
* |
18
|
|
|
* @property Form $form |
19
|
|
|
* @property SolicitudeValue $values |
20
|
|
|
*/ |
21
|
|
|
class Solicitude extends \roaresearch\yii2\rmdb\models\Entity |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var string full class name of the model used in the relation |
25
|
|
|
* `getForm()`. |
26
|
|
|
*/ |
27
|
|
|
protected $formClass = Form::class; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string full class name of the model used in the relation |
31
|
|
|
* `getSolicitudeValues()`. |
32
|
|
|
*/ |
33
|
|
|
protected $solicitudeValueClass = SolicitudeValue::class; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @inheritdoc |
37
|
|
|
*/ |
38
|
14 |
|
public static function tableName() |
39
|
|
|
{ |
40
|
14 |
|
return '{{%formgenerator_solicitude}}'; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @inheritdoc |
45
|
|
|
*/ |
46
|
11 |
|
protected function attributeTypecast(): array |
47
|
|
|
{ |
48
|
11 |
|
return parent::attributeTypecast() + [ |
49
|
11 |
|
'id' => 'integer', |
50
|
|
|
'form_id' => 'integer', |
51
|
|
|
]; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @inheritdoc |
56
|
|
|
*/ |
57
|
2 |
|
public function rules() |
58
|
|
|
{ |
59
|
|
|
return [ |
60
|
2 |
|
[['form_id'], 'required'], |
61
|
|
|
[['form_id'], 'integer'], |
62
|
|
|
[ |
63
|
|
|
['form_id'], |
64
|
|
|
'exist', |
65
|
|
|
'skipOnError' => true, |
66
|
|
|
'targetClass' => Form::class, |
67
|
|
|
'targetAttribute' => ['form_id' => 'id'], |
68
|
|
|
], |
69
|
|
|
]; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @inheritdoc |
74
|
|
|
*/ |
75
|
2 |
|
public function attributeLabels() |
76
|
|
|
{ |
77
|
2 |
|
return array_merge([ |
78
|
2 |
|
'id' => 'ID', |
79
|
|
|
'form_id' => 'Form ID', |
80
|
2 |
|
], parent::attributeLabels()); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return ActiveQuery |
85
|
|
|
*/ |
86
|
11 |
|
public function getForm(): ActiveQuery |
87
|
|
|
{ |
88
|
11 |
|
return $this->hasOne($this->formClass, ['id' => 'form_id']); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return ActiveQuery |
93
|
|
|
*/ |
94
|
|
|
public function getValues(): ActiveQuery |
95
|
|
|
{ |
96
|
|
|
return $this->hasMany( |
97
|
|
|
$this->solicitudeValueClass, |
98
|
|
|
['solicitude_id' => 'id'] |
99
|
|
|
)->inverseOf('solicitude'); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|