1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace zacksleo\yii2\cms\models; |
4
|
|
|
|
5
|
|
|
use Yii; |
6
|
|
|
use zacksleo\yii2\cms\Module; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* This is the model class for table "{{%menu}}". |
10
|
|
|
* |
11
|
|
|
* @property integer $id |
12
|
|
|
* @property string $title |
13
|
|
|
* @property integer $order |
14
|
|
|
* @property integer $parent |
15
|
|
|
* @property string $url |
16
|
|
|
* @property Menu[] $children |
17
|
|
|
* @property Menu $father |
18
|
|
|
*/ |
19
|
|
|
class Menu extends \yii\db\ActiveRecord |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @inheritdoc |
23
|
|
|
*/ |
24
|
3 |
|
public static function tableName() |
25
|
|
|
{ |
26
|
3 |
|
return '{{%menu}}'; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @inheritdoc |
31
|
|
|
*/ |
32
|
2 |
|
public function rules() |
33
|
|
|
{ |
34
|
|
|
return [ |
35
|
2 |
|
[['title', 'url'], 'required'], |
36
|
2 |
|
['parent', 'default', 'value' => 0], |
37
|
2 |
|
[['order', 'parent'], 'integer'], |
38
|
2 |
|
[['title', 'url'], 'string', 'max' => 255], |
39
|
2 |
|
]; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @inheritdoc |
44
|
|
|
*/ |
45
|
1 |
|
public function attributeLabels() |
46
|
|
|
{ |
47
|
|
|
return [ |
48
|
1 |
|
'id' => Module::t('cms', 'ID'), |
49
|
1 |
|
'title' => Module::t('cms', 'Title'), |
50
|
1 |
|
'order' => Module::t('cms', 'Order'), |
51
|
1 |
|
'parent' => Module::t('cms', 'Parent'), |
52
|
1 |
|
'url' => Module::t('cms', 'Url'), |
53
|
1 |
|
]; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return \yii\db\ActiveQuery |
58
|
|
|
*/ |
59
|
1 |
|
public function getChildren() |
60
|
|
|
{ |
61
|
1 |
|
return $this->hasMany(self::className(), ['parent' => 'id'])->orderBy('order'); |
|
|
|
|
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return \yii\db\ActiveQuery |
66
|
|
|
*/ |
67
|
1 |
|
public function getFather() |
68
|
|
|
{ |
69
|
1 |
|
return $this->hasOne(self::className(), [ |
|
|
|
|
70
|
|
|
'id' => 'parent' |
71
|
1 |
|
]); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.