1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Hosting Plugin for HiPanel |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-hosting |
6
|
|
|
* @package hipanel-module-hosting |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hipanel\modules\hosting\models; |
12
|
|
|
|
13
|
|
|
use hipanel\base\Model; |
14
|
|
|
use hipanel\base\ModelTrait; |
15
|
|
|
use hipanel\modules\hosting\models\query\PrefixQuery; |
16
|
|
|
use Yii; |
17
|
|
|
use yii\db\QueryInterface; |
18
|
|
|
|
19
|
|
|
class Prefix extends Model |
20
|
|
|
{ |
21
|
|
|
use ModelTrait; |
22
|
|
|
|
23
|
|
|
/** {@inheritdoc} */ |
24
|
|
|
public function rules() |
25
|
|
|
{ |
26
|
|
|
return array_merge(parent::rules(), [ |
27
|
|
|
[['id', 'client_id', 'seller_id', 'utilization', 'aggregate_id', 'ip_count'], 'integer'], |
28
|
|
|
[['note', 'vrf', 'role', 'site', 'state', 'type', 'client', 'seller', 'vlan_group', 'vlan', 'aggregate'], 'string'], |
29
|
|
|
[['ip'], 'ip', 'subnet' => null], |
30
|
|
|
|
31
|
|
|
[['ip', 'vrf', 'type'], 'required', 'on' => ['create', 'update']], |
32
|
|
|
[['id', 'note'], 'required', 'on' => ['set-note']], |
33
|
|
|
]); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** {@inheritdoc} */ |
37
|
|
|
public function attributeLabels() |
38
|
|
|
{ |
39
|
|
|
return $this->mergeAttributeLabels([ |
40
|
|
|
'ip' => Yii::t('hipanel.hosting.ipam', 'Prefix'), |
41
|
|
|
'type' => Yii::t('hipanel.hosting.ipam', 'Status'), |
42
|
|
|
'vrf' => Yii::t('hipanel.hosting.ipam', 'VRF'), |
43
|
|
|
'site' => Yii::t('hipanel.hosting.ipam', 'Site'), |
44
|
|
|
'note' => Yii::t('hipanel.hosting.ipam', 'Description'), |
45
|
|
|
'vlan' => Yii::t('hipanel.hosting.ipam', 'VLAN'), |
46
|
|
|
'vlan_group' => Yii::t('hipanel.hosting.ipam', 'VLAN group'), |
47
|
|
|
]); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@inheritdoc} |
52
|
|
|
* @return PrefixQuery |
53
|
|
|
*/ |
54
|
|
|
public static function find(array $options = []): QueryInterface |
55
|
|
|
{ |
56
|
|
|
return new PrefixQuery(get_called_class(), [ |
57
|
|
|
'options' => $options, |
58
|
|
|
]); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|