Completed
Push — master ( 4b68e3...9b100e )
by Andrii
15:11 queued 11:25
created

HardwareSettings::attributeLabels()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 7
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Server module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-server
6
 * @package   hipanel-module-server
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\server\models;
12
13
use Yii;
14
15
class HardwareSettings extends \hipanel\base\Model
16
{
17
    const SCENARIO_DEFAULT = 'dumb';
18
19
    public static function tableName()
20
    {
21
        return 'server';
22
    }
23
24
    public static function primaryKey()
25
    {
26
        return ['id'];
27
    }
28
29
    public function scenarioActions()
30
    {
31
        return [
32
            'default' => 'set-hardware-settings',
33
            'set-units' => 'set-hardware-settings',
34
            'set-rack-no' => 'set-hardware-settings',
35
        ];
36
    }
37
38
    public function rules()
39
    {
40
        return [
41
            [['id'], 'integer'],
42
            [
43
                [
44
                    'summary', 'order_no', 'brand', 'box', 'cpu', 'ram', 'motherboard', 'hdd', 'hotswap', 'raid',
45
                    'units', 'note', 'cage_no', 'rack_no', 'datacenter',
46
                ], 'string',
47
            ],
48
            [['id', 'units'], 'required', 'on' => 'set-units'],
49
            [['id', 'rack_no'], 'required', 'on' => 'set-rack-no'],
50
        ];
51
    }
52
53
    public function attributeLabels()
54
    {
55
        return $this->mergeAttributeLabels([
56
            'summary' => Yii::t('hipanel:server', 'Hardware Summary'),
57
            'order_no' => Yii::t('hipanel:server', 'Order number'),
58
            'Units' => Yii::t('hipanel:server', 'Units'),
59
            'Motherboard' => Yii::t('hipanel:server', 'Motherboard'),
60
        ]);
61
    }
62
}
63