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\helpers\StringHelper; |
16
|
|
|
use Yii; |
17
|
|
|
|
18
|
|
|
class Service extends Model |
19
|
|
|
{ |
20
|
|
|
use ModelTrait; |
21
|
|
|
|
22
|
|
|
/** {@inheritdoc} */ |
23
|
|
|
public function rules() |
24
|
|
|
{ |
25
|
|
|
return [ |
26
|
|
|
[['id', 'server_id', 'device_id', 'client_id', 'seller_id', 'soft_id'], 'integer'], |
27
|
|
|
[['name', 'server', 'device', 'client', 'seller', 'soft'], 'safe'], |
28
|
|
|
[['ip', 'ips', 'bin', 'etc', 'objects_count'], 'safe'], |
29
|
|
|
[['soft_type', 'soft_type_label', 'state', 'state_label'], 'safe'], |
30
|
|
|
[['server'], 'safe', 'on' => ['create']], |
31
|
|
|
[['bin', 'etc', 'soft', 'state'], 'safe', 'on' => ['create', 'update']], |
32
|
|
|
[['ips'], 'filter', |
33
|
|
|
'filter' => function ($value) { |
34
|
|
|
return StringHelper::explode($value); |
35
|
|
|
}, |
36
|
|
|
'skipOnArray' => true, 'on' => ['create', 'update'], |
37
|
|
|
], |
38
|
|
|
[['ips'], 'each', 'rule' => ['ip'], 'on' => ['create', 'update']], |
39
|
|
|
[['server', 'name', 'etc', 'bin', 'soft', 'state', 'ips'], 'required', 'on' => ['create', 'update']], |
40
|
|
|
[['id', 'server'], 'required', 'on' => ['update']], |
41
|
|
|
[['id'], 'required', 'on' => ['update']], |
42
|
|
|
]; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** {@inheritdoc} */ |
46
|
|
|
public function attributeLabels() |
47
|
|
|
{ |
48
|
|
|
return $this->mergeAttributeLabels([ |
49
|
|
|
'soft_type' => Yii::t('hipanel', 'Type'), |
50
|
|
|
'bin' => Yii::t('hipanel:hosting', 'bin'), |
51
|
|
|
'etc' => Yii::t('hipanel:hosting', 'etc'), |
52
|
|
|
'soft' => Yii::t('hipanel:hosting', 'Soft'), |
53
|
|
|
]); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function getIps() |
57
|
|
|
{ |
58
|
|
|
return $this->hasMany(Ip::class, ['service_id', 'id']); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function getPageTitle() |
62
|
|
|
{ |
63
|
|
|
return implode(': ', array_filter([$this->server, $this->name])); |
|
|
|
|
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@property
annotation 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.