|
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-2016, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace hipanel\modules\hosting\models; |
|
12
|
|
|
|
|
13
|
|
|
use yii\web\JsExpression; |
|
14
|
|
|
|
|
15
|
|
|
class Link extends \hipanel\base\Model |
|
16
|
|
|
{ |
|
17
|
|
|
use \hipanel\base\ModelTrait; |
|
18
|
|
|
|
|
19
|
|
|
public static function from() |
|
20
|
|
|
{ |
|
21
|
|
|
return 'ip'; |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function rules() |
|
25
|
|
|
{ |
|
26
|
|
|
return [ |
|
27
|
|
|
[['id', 'ip_id', 'device_id', 'service_id', 'soft_id'], 'integer'], |
|
28
|
|
|
[['ip', 'service', 'soft', 'soft_type', 'soft_type_label', 'device_ptype'], 'safe'], |
|
29
|
|
|
[['device'], 'safe', 'on' => ['create', 'update']], |
|
30
|
|
|
[['service_id', 'ip_id', 'id'], 'integer', 'on' => ['create', 'update']], |
|
31
|
|
|
[['id'], 'required', 'on' => ['delete']], |
|
32
|
|
|
[['service_id'], 'required', 'when' => function ($model) { |
|
|
|
|
|
|
33
|
|
|
return !empty($this->server); |
|
|
|
|
|
|
34
|
|
|
}, 'whenClient' => new JsExpression("function (attribute, value) { |
|
35
|
|
|
return $(attribute).parent('.item').find('[data-attribute=server]').val(); |
|
36
|
|
|
}"), 'on' => ['create', 'update']], |
|
37
|
|
|
]; |
|
38
|
|
|
} |
|
39
|
|
|
} |
|
40
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.