1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace app\core\requests; |
4
|
|
|
|
5
|
|
|
use app\core\models\User; |
6
|
|
|
use app\core\types\CurrencyCode; |
7
|
|
|
|
8
|
|
|
class JoinRequest extends \yii\base\Model |
9
|
|
|
{ |
10
|
|
|
public $username; |
11
|
|
|
public $email; |
12
|
|
|
public $password; |
13
|
|
|
public $base_currency_code; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @inheritdoc |
17
|
|
|
*/ |
18
|
|
|
public function rules() |
19
|
|
|
{ |
20
|
|
|
return [ |
21
|
|
|
[['username', 'email'], 'trim'], |
22
|
|
|
[['username', 'email', 'base_currency_code'], 'required'], |
23
|
|
|
|
24
|
|
|
['username', 'unique', 'targetClass' => User::class], |
25
|
|
|
['username', 'string', 'min' => 3, 'max' => 60], |
26
|
|
|
|
27
|
|
|
['email', 'string', 'min' => 2, 'max' => 120], |
28
|
|
|
['email', 'unique', 'targetClass' => User::class], |
29
|
|
|
['email', 'email'], |
30
|
|
|
|
31
|
|
|
['password', 'required'], |
32
|
|
|
['password', 'string', 'min' => 6], |
33
|
|
|
|
34
|
|
|
['base_currency_code', 'in', 'range' => CurrencyCode::getKeys()], |
35
|
|
|
]; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @inheritdoc |
40
|
|
|
*/ |
41
|
|
|
public function attributeLabels() |
42
|
|
|
{ |
43
|
|
|
return [ |
44
|
|
|
'username' => t('app', 'Username'), |
45
|
|
|
'password' => t('app', 'Password'), |
46
|
|
|
'email' => t('app', 'Email'), |
47
|
|
|
'base_currency_code' => t('app', 'Base Currency Code'), |
48
|
|
|
]; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|