Region.php
2.18 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
namespace common\modules\location\models;
use Yii;
use thread\app\base\models\ActiveRecord;
use thread\modules\location\Location as MainModule;
/**
* Class Region
*
* @property integer id
* @property integer position
* @property integer created_at
* @property integer updated_at
* @property boolean published
* @property boolean deleted
* @property \yii\db\ActiveQuery $lang
*
* @author Alla Kuzmenko
* @package common\modules\location\models
*/
class Region extends ActiveRecord
{
const moduleName = 'location';
/**
* @return null|object|string
*/
public static function getDb()
{
return MainModule::getDb();
}
/**
* @return string
*/
public static function tableName()
{
return '{{%location_region}}';
}
/**
* @return array
*/
public function rules()
{
return [
[['created_at', 'updated_at', 'position'], 'integer'],
[['published', 'deleted'], 'in', 'range' => array_keys(static::statusKeyRange())],
];
}
/**
* @return array
*/
public function scenarios()
{
return [
'published' => ['published'],
'deleted' => ['deleted'],
'position' => ['position'],
'backend' => [
'position',
'published',
'deleted'
]
];
}
/**
* @return array
*/
public function attributeLabels()
{
return [
'id' => Yii::t('app', 'ID'),
'position' => Yii::t('app', 'Position'),
'created_at' => Yii::t('app', 'Create time'),
'updated_at' => Yii::t('app', 'Update time'),
'published' => Yii::t('app', 'Published'),
'deleted' => Yii::t('app', 'Deleted'),
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getLang()
{
return $this->hasOne(RegionLang::class, ['rid' => 'id']);
}
/**
* @return Module|null the module instance, `null` if the module does not exist.
*/
public static function getModule()
{
return Yii::$app->getModule(self::moduleName);
}
}