HardwareSettings::tableName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
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
/**
16
 * Class HardwareSettings
17
 *
18
 * @author Dmytro Naumenko <[email protected]>
19
 *
20
 * @property float|int|string $units numeric units number (e.g. 1), or a fraction (3/5)
21
 */
22
class HardwareSettings extends \hipanel\base\Model
23
{
24
    const SCENARIO_DEFAULT = 'dumb';
25
26
    public static function tableName()
27
    {
28
        return 'server';
29
    }
30
31
    public static function primaryKey()
32
    {
33
        return ['id'];
34
    }
35
36
    public function scenarioActions()
37
    {
38
        return [
39
            'default' => 'set-hardware-settings',
40
            'set-units' => 'set-hardware-settings',
41
            'set-rack-no' => 'set-hardware-settings',
42
        ];
43
    }
44
45
    public function rules()
46
    {
47
        return [
48
            [['id'], 'integer'],
49
            [
50
                [
51
                    'summary', 'order_no', 'brand', 'box', 'cpu', 'ram', 'motherboard', 'hdd', 'hotswap', 'raid',
52
                    'units', 'note', 'cage_no', 'rack_no', 'datacenter',
53
                ], 'string',
54
            ],
55
            [['id', 'units'], 'required', 'on' => 'set-units'],
56
            [['id', 'rack_no'], 'required', 'on' => 'set-rack-no'],
57
        ];
58
    }
59
60
    public function attributeLabels()
61
    {
62
        return $this->mergeAttributeLabels([
63
            'summary' => Yii::t('hipanel:server', 'Hardware Summary'),
64
            'order_no' => Yii::t('hipanel:server', 'Order number'),
65
            'units' => Yii::t('hipanel:server', 'Units'),
66
            'motherboard' => Yii::t('hipanel:server', 'Motherboard'),
67
        ]);
68
    }
69
}
70