|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace modules\users\models; |
|
4
|
|
|
|
|
5
|
|
|
use Yii; |
|
6
|
|
|
use yii\behaviors\TimestampBehavior; |
|
7
|
|
|
use modules\users\traits\ModuleTrait; |
|
8
|
|
|
use modules\users\Module; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* This is the model class for table "{{%user_profile}}". |
|
12
|
|
|
* |
|
13
|
|
|
* @property int $id ID |
|
14
|
|
|
* @property int $user_id User |
|
15
|
|
|
* @property string $first_name First Name |
|
16
|
|
|
* @property string $last_name Last Name |
|
17
|
|
|
* @property string $email_gravatar Email Gravatar |
|
18
|
|
|
* @property int $last_visit Last Visit |
|
19
|
|
|
* @property int $created_at Created |
|
20
|
|
|
* @property int $updated_at Updated |
|
21
|
|
|
* |
|
22
|
|
|
* @property User $user |
|
23
|
|
|
*/ |
|
24
|
|
|
class UserProfile extends \yii\db\ActiveRecord |
|
25
|
|
|
{ |
|
26
|
|
|
use ModuleTrait; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* {@inheritdoc} |
|
30
|
|
|
*/ |
|
31
|
|
|
public static function tableName() |
|
32
|
|
|
{ |
|
33
|
|
|
return '{{%user_profile}}'; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function behaviors() |
|
37
|
|
|
{ |
|
38
|
|
|
return [ |
|
39
|
|
|
'timestamp' => [ |
|
40
|
|
|
'class' => TimestampBehavior::class, |
|
41
|
|
|
], |
|
42
|
|
|
]; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* {@inheritdoc} |
|
47
|
|
|
*/ |
|
48
|
|
|
public function rules() |
|
49
|
|
|
{ |
|
50
|
|
|
return [ |
|
51
|
|
|
[['user_id'], 'required'], |
|
52
|
|
|
[['user_id', 'last_visit', 'created_at', 'updated_at'], 'integer'], |
|
53
|
|
|
[['first_name', 'last_name'], 'string', 'max' => 255], |
|
54
|
|
|
[['email_gravatar'], 'email'], |
|
55
|
|
|
[['email_gravatar'], 'unique'], |
|
56
|
|
|
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::class, 'targetAttribute' => ['user_id' => 'id']], |
|
57
|
|
|
]; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* {@inheritdoc} |
|
62
|
|
|
*/ |
|
63
|
|
|
public function attributeLabels() |
|
64
|
|
|
{ |
|
65
|
|
|
return [ |
|
66
|
|
|
'id' => Module::t('module', 'ID'), |
|
67
|
|
|
'user_id' => Module::t('module', 'User'), |
|
68
|
|
|
'first_name' => Module::t('module', 'First Name'), |
|
69
|
|
|
'last_name' => Module::t('module', 'Last Name'), |
|
70
|
|
|
'email_gravatar' => Module::t('module', 'Email Gravatar'), |
|
71
|
|
|
'last_visit' => Module::t('module', 'Last Visit'), |
|
72
|
|
|
'created_at' => Module::t('module', 'Created'), |
|
73
|
|
|
'updated_at' => Module::t('module', 'Updated'), |
|
74
|
|
|
]; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @return \yii\db\ActiveQuery |
|
79
|
|
|
*/ |
|
80
|
|
|
public function getUser() |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->hasOne(User::class, ['id' => 'user_id']); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|