1
|
|
|
<?php
|
2
|
|
|
/**
|
3
|
|
|
* @author Alexey Tatarinov <[email protected]>
|
4
|
|
|
* @link https://github.com/shogodev/argilla/
|
5
|
|
|
* @copyright Copyright © 2003-2014 Shogo
|
6
|
|
|
* @license http://argilla.ru/LICENSE
|
7
|
|
|
* @package frontend.models.user
|
8
|
|
|
*
|
9
|
|
|
* @method static UserProfile model(string $class = __CLASS__)
|
10
|
|
|
*
|
11
|
|
|
* @property integer $user_id
|
12
|
|
|
* @property string $name
|
13
|
|
|
* @property string $last_name
|
14
|
|
|
* @property string $patronymic
|
15
|
|
|
* @property string $address
|
16
|
|
|
* @property string $phone
|
17
|
|
|
* @property string $birthday
|
18
|
|
|
* @property string $discount
|
19
|
|
|
*/
|
20
|
|
|
class UserProfile extends FActiveRecord
|
21
|
|
|
{
|
22
|
9 |
|
public function rules()
|
23
|
|
|
{
|
24
|
|
|
return array(
|
25
|
9 |
|
array('name', 'required', 'except' => User::SCENARIO_REGISTRATION),
|
26
|
9 |
|
array('name, last_name, patronymic, address, birthday, phone', 'safe'),
|
27
|
9 |
|
);
|
28
|
|
|
}
|
29
|
|
|
|
30
|
9 |
|
public function behaviors()
|
31
|
|
|
{
|
32
|
|
|
return array(
|
33
|
|
|
'dateFormatBehavior' => array(
|
34
|
9 |
|
'class' => 'DateFormatBehavior',
|
35
|
9 |
|
'attribute' => 'birthday',
|
36
|
|
|
)
|
37
|
9 |
|
);
|
38
|
|
|
}
|
39
|
|
|
|
40
|
3 |
View Code Duplication |
public function attributeLabels()
|
|
|
|
|
41
|
|
|
{
|
42
|
3 |
|
return CMap::mergeArray(parent::attributeLabels(), array(
|
43
|
3 |
|
'name' => 'Имя',
|
44
|
3 |
|
'last_name' => 'Фамилия',
|
45
|
3 |
|
'patronymic' => 'Отчество',
|
46
|
3 |
|
'phone' => 'Контактный телефон',
|
47
|
3 |
|
'address' => 'Адрес',
|
48
|
3 |
|
'bicycle' => 'Модель велосипеда',
|
49
|
3 |
|
'birthday' => 'Дата рождения',
|
50
|
|
|
'discount' => 'Персональная скидка'
|
51
|
3 |
|
));
|
52
|
|
|
}
|
53
|
|
|
} |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.