Completed
Push — master ( d26825...dc6239 )
by Klochok
11:38
created

Aggregate::find()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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\AggregateQuery;
16
use Yii;
17
use yii\db\QueryInterface;
18
19
class Aggregate 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'], 'integer'],
28
            [['note', 'rir', 'state', 'type', 'client', 'seller'], 'string'],
29
            [['ip'], 'ip', 'subnet' => null],
30
31
            [['ip', 'rir'], 'required', 'on' => ['create', 'update']],
32
            [['id'], 'required', 'on' => ['update']],
33
            [['id', 'note'], 'required', 'on' => ['set-note']],
34
        ]);
35
    }
36
37
    /** {@inheritdoc} */
38
    public function attributeLabels()
39
    {
40
        return $this->mergeAttributeLabels([
41
            'ip' => Yii::t('hipanel.hosting.ipam', 'Aggregate'),
42
            'rir' => Yii::t('hipanel.hosting.ipam', 'RIR'),
43
            'note' => Yii::t('hipanel.hosting.ipam', 'Description'),
44
        ]);
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     * @return QueryInterface
50
     */
51
    public static function find(array $options = []): QueryInterface
52
    {
53
        return new AggregateQuery(get_called_class(), [
54
            'options' => $options,
55
        ]);
56
    }
57
}
58