1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Finance module for HiPanel |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-finance |
6
|
|
|
* @package hipanel-module-finance |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hipanel\modules\finance\models; |
12
|
|
|
|
13
|
|
|
use Yii; |
14
|
|
|
|
15
|
|
|
class DomainServicePrice extends Price |
16
|
|
|
{ |
17
|
|
|
const FEATURE_PREMIUM_DNS_PURCHASE = 'feature,premium_dns_purchase'; |
18
|
|
|
const FEATURE_PREMIUM_DNS_RENEW = 'feature,premium_dns_renew'; |
19
|
|
|
const FEATURE_WHOIS_PROTECT_PURCHASE = 'feature,whois_protect_purchase'; |
20
|
|
|
const FEATURE_WHOIS_PROTECT_RENEW = 'feature,whois_protect_renew'; |
21
|
|
|
|
22
|
|
|
public static function tableName() |
23
|
|
|
{ |
24
|
|
|
return 'price'; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function rules() |
28
|
|
|
{ |
29
|
|
|
$rules = parent::rules(); |
30
|
|
|
$rules['create-required-price'] = [['price'], 'required']; |
31
|
|
|
$rules[] = [['price'], 'number', 'min' => 0]; |
32
|
|
|
|
33
|
|
|
return $rules; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @return array available operations |
38
|
|
|
*/ |
39
|
|
|
public static function getOperations(): array |
40
|
|
|
{ |
41
|
|
|
return [ |
42
|
|
|
static::FEATURE_PREMIUM_DNS_PURCHASE => Yii::t('hipanel:finance:tariff', 'Purchase'), |
43
|
|
|
static::FEATURE_PREMIUM_DNS_RENEW => Yii::t('hipanel:finance:tariff', 'Renewal'), |
44
|
|
|
static::FEATURE_WHOIS_PROTECT_PURCHASE => Yii::t('hipanel:finance:tariff', 'Purchase'), |
45
|
|
|
static::FEATURE_WHOIS_PROTECT_RENEW => Yii::t('hipanel:finance:tariff', 'Renewal'), |
46
|
|
|
]; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return string|null |
51
|
|
|
*/ |
52
|
|
|
public static function getLabel(string $labelType): ?string |
53
|
|
|
{ |
54
|
|
|
$variants = [ |
55
|
|
|
'premium_dns' => Yii::t('hipanel:finance:tariff', 'Premium DNS'), |
56
|
|
|
'whois_protect' => Yii::t('hipanel:finance:tariff', 'WHOIS Protect'), |
57
|
|
|
]; |
58
|
|
|
|
59
|
|
|
return $variants[$labelType]; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|