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
|
|
|
namespace hipanel\modules\server\models; |
11
|
|
|
|
12
|
|
|
use hipanel\base\Model; |
13
|
|
|
use hipanel\base\ModelTrait; |
14
|
|
|
use Yii; |
15
|
|
|
|
16
|
|
|
class Config extends Model |
17
|
|
|
{ |
18
|
|
|
use ModelTrait; |
19
|
|
|
|
20
|
|
|
const SCENARIO_CREATE = 'create'; |
21
|
|
|
const SCENARIO_UPDATE = 'update'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* {@inheritdoc} |
25
|
|
|
*/ |
26
|
|
|
public function rules() |
27
|
|
|
{ |
28
|
|
|
return array_merge(parent::rules(), [ |
29
|
|
|
[['id', 'client_id', 'type_id', 'state_id'], 'integer'], |
30
|
|
|
[['name', 'client', 'state', 'state_label', 'type', 'type_label'], 'string'], |
31
|
|
|
[['sort_order'], 'integer', 'min'=>0], |
32
|
|
|
[ |
33
|
|
|
[ |
34
|
|
|
'data', |
35
|
|
|
'name', |
36
|
|
|
'label', |
37
|
|
|
'cpu', |
38
|
|
|
'ram', |
39
|
|
|
'hdd', |
40
|
|
|
'ssd', |
41
|
|
|
'traffic', |
42
|
|
|
'lan', |
43
|
|
|
'raid', |
44
|
|
|
'descr', |
45
|
|
|
], 'string'], |
46
|
|
|
[ |
47
|
|
|
['client_id', 'name', 'label', 'cpu', 'ram'], |
48
|
|
|
'required', 'on' => ['create', 'update'], |
49
|
|
|
], |
50
|
|
|
|
51
|
|
|
['id', 'required', 'on' => 'delete'] |
52
|
|
|
]); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function attributeLabels() |
56
|
|
|
{ |
57
|
|
|
return array_merge(parent::attributeLabels(), [ |
58
|
|
|
'label' => 'Subname', |
59
|
|
|
'cpu' => 'CPU', |
60
|
|
|
'ram' => 'RAM', |
61
|
|
|
'hdd' => 'HDD', |
62
|
|
|
'ssd' => 'SSD', |
63
|
|
|
'lan' => 'LAN', |
64
|
|
|
'raid' => 'RAID', |
65
|
|
|
'sort_order' => 'Sort order', |
66
|
|
|
]); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|