|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Hosting Plugin for HiPanel |
|
5
|
|
|
* |
|
6
|
|
|
* @link https://github.com/hiqdev/hipanel-module-hosting |
|
7
|
|
|
* @package hipanel-module-hosting |
|
8
|
|
|
* @license BSD-3-Clause |
|
9
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace hipanel\modules\hosting\models; |
|
13
|
|
|
|
|
14
|
|
|
use hipanel\helpers\StringHelper; |
|
15
|
|
|
use Yii; |
|
16
|
|
|
|
|
17
|
|
|
class Service extends \hipanel\base\Model |
|
18
|
|
|
{ |
|
19
|
|
|
use \hipanel\base\ModelTrait; |
|
20
|
|
|
|
|
21
|
|
|
/** @inheritdoc */ |
|
22
|
|
|
public function rules() |
|
23
|
|
|
{ |
|
24
|
|
|
return [ |
|
25
|
|
|
[['id', 'server_id', 'device_id', 'client_id', 'seller_id', 'soft_id'], 'integer'], |
|
26
|
|
|
[['name', 'server', 'device', 'client', 'seller', 'soft'], 'safe'], |
|
27
|
|
|
[['ip', 'ips', 'bin', 'etc', 'objects_count'], 'safe'], |
|
28
|
|
|
[['soft_type', 'soft_type_label', 'state', 'state_label'], 'safe'], |
|
29
|
|
|
[['server'], 'safe', 'on' => ['create']], |
|
30
|
|
|
[['bin', 'etc', 'soft', 'state'], 'safe', 'on' => ['create', 'update']], |
|
31
|
|
|
[['ips'], 'filter', |
|
32
|
|
|
'filter' => function ($value) { |
|
33
|
|
|
return StringHelper::explode($value); |
|
34
|
|
|
}, |
|
35
|
|
|
'skipOnArray' => true, 'on' => ['create', 'update'] |
|
36
|
|
|
], |
|
37
|
|
|
[['ips'], 'each', 'rule' => ['ip'], 'on' => ['create', 'update']], |
|
38
|
|
|
[['id'], 'integer', 'on' => ['update']], |
|
39
|
|
|
[['id'], 'required', 'on' => ['update']], |
|
40
|
|
|
]; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** @inheritdoc */ |
|
44
|
|
|
public function attributeLabels() |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->mergeAttributeLabels([ |
|
47
|
|
|
'soft_type' => Yii::t('hipanel', 'Type'), |
|
48
|
|
|
'bin' => Yii::t('hipanel/hosting', 'bin'), |
|
49
|
|
|
'etc' => Yii::t('hipanel/hosting', 'etc'), |
|
50
|
|
|
'soft' => Yii::t('hipanel/hosting', 'Soft'), |
|
51
|
|
|
]); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function getIps() |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->hasMany(Ip::class, ['service_id', 'id']); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|