|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Finance module for HiPanel |
|
5
|
|
|
* |
|
6
|
|
|
* @link https://github.com/hiqdev/hipanel-module-finance |
|
7
|
|
|
* @package hipanel-module-finance |
|
8
|
|
|
* @license BSD-3-Clause |
|
9
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace hipanel\modules\finance\models; |
|
13
|
|
|
|
|
14
|
|
|
use hipanel\base\ModelTrait; |
|
15
|
|
|
use Yii; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Class DomainResource |
|
19
|
|
|
* @package hipanel\modules\finance\models |
|
20
|
|
|
*/ |
|
21
|
|
|
class ServerResource extends Resource |
|
22
|
|
|
{ |
|
23
|
|
|
use ModelTrait; |
|
24
|
|
|
|
|
25
|
|
|
public static function index() |
|
26
|
|
|
{ |
|
27
|
|
|
return 'resources'; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public static function type() |
|
31
|
|
|
{ |
|
32
|
|
|
return 'resource'; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
const MODEL_TYPE_CPU = 'cpu'; |
|
36
|
|
|
const MODEL_TYPE_RAM = 'ram'; |
|
37
|
|
|
const MODEL_TYPE_HDD = 'hdd'; |
|
38
|
|
|
const MODEL_TYPE_CHASSIS = 'chassis'; |
|
39
|
|
|
|
|
40
|
|
|
public function rules() |
|
41
|
|
|
{ |
|
42
|
|
|
$rules = parent::rules(); |
|
43
|
|
|
$rules[] = [['model_type', 'partno'], 'safe']; |
|
44
|
|
|
|
|
45
|
|
|
return $rules; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @return array |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getModelTypes() |
|
52
|
|
|
{ |
|
53
|
|
|
return [ |
|
54
|
|
|
static::MODEL_TYPE_CPU => Yii::t('hipanel/finance/tariff', 'CPU'), |
|
55
|
|
|
static::MODEL_TYPE_RAM => Yii::t('hipanel/finance/tariff', 'RAM'), |
|
56
|
|
|
static::MODEL_TYPE_HDD => Yii::t('hipanel/finance/tariff', 'HDD'), |
|
57
|
|
|
static::MODEL_TYPE_CHASSIS => Yii::t('hipanel/finance/tariff', 'Chassis'), |
|
58
|
|
|
]; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function isModelTypeCorrect() |
|
62
|
|
|
{ |
|
63
|
|
|
return isset($this->getModelTypes()[$this->model_type]); |
|
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.