Completed
Push — master ( 92156c...43c17e )
by Andrii
25:32 queued 10:20
created

Prefix::attributeLabels()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
18
class Prefix extends Model
19
{
20
    use ModelTrait;
21
22
    /** {@inheritdoc} */
23
    public function rules()
24
    {
25
        return array_merge(parent::rules(), [
26
            [['id', 'client_id', 'seller_id'], 'integer'],
27
            [['note', 'vrf', 'role', 'site', 'state', 'type', 'client', 'seller', 'vlan_group', 'vlan'], 'string'],
28
            [['ip'], 'ip', 'subnet' => null],
29
30
            [['ip', 'vrf', 'state'], 'required', 'on' => ['create', 'update']],
31
        ]);
32
    }
33
34
    /** {@inheritdoc} */
35
    public function attributeLabels()
36
    {
37
        return $this->mergeAttributeLabels([
38
            'ip' => Yii::t('hipanel.hosting.ipam', 'Prefix'),
39
            'vrf' => Yii::t('hipanel.hosting.ipam', 'VRF'),
40
            'note' => Yii::t('hipanel.hosting.ipam', 'Description'),
41
            'vlan' => Yii::t('hipanel.hosting.ipam', 'VLAN'),
42
            'vlan_group' => Yii::t('hipanel.hosting.ipam', 'VLAN group'),
43
        ]);
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     * @return PrefixQuery
49
     */
50
    public static function find(array $options = []): PrefixQuery
51
    {
52
        return new PrefixQuery(get_called_class(), [
53
            'options' => $options,
54
        ]);
55
    }
56
}
57