Options.php
1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
namespace frontend\models;
use Yii;
/**
* This is the model class for table "option".
*
* @property integer $option_id
* @property string $option_key
* @property integer $option_parent
* @property integer $option_translatable
* @property string $option_format
*
* @property OptionValues[] $optionValues
* @property Options $optionParent
* @property Options[] $options
*/
class Options extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName ()
{
return 'option';
}
/**
* @inheritdoc
*/
public function rules ()
{
return [
[['option_key'], 'required'], [['option_parent', 'option_translatable'], 'integer'], [['option_key', 'option_format'], 'string', 'max' => 200]
];
}
/**
* @inheritdoc
*/
public function attributeLabels ()
{
return [
'option_id' => Yii::t ('app', 'Option ID'), 'option_key' => Yii::t ('app', 'Option Key'), 'option_parent' => Yii::t ('app', 'Option Parent'), 'option_translatable' => Yii::t ('app', 'Option Translatable'), 'option_format' => Yii::t ('app', 'Option Format'),
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getOptionLang ()
{
return $this->hasMany (OptionLang::className (), ['option_id' => 'option_id']);
}
public function getValue ()
{
return $this->hasOne(OptionLang::className(), ['option_id' => 'option_id'])->where(['option_lang.language_id' => '0']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getOptionParent()
{
return $this->hasOne(Options::className(), ['option_id' => 'option_parent']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getOptions()
{
return $this->hasMany(Options::className(), ['option_parent' => 'option_id']);
}
}