1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace app\models\entity; |
4
|
|
|
|
5
|
|
|
use Yii; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* This is the model class for table "{{%user_profile}}". |
9
|
|
|
* |
10
|
|
|
* @property integer $user_id |
11
|
|
|
* @property string $full_name |
12
|
|
|
* @property string $photo |
13
|
|
|
* @property string $birth_day |
14
|
|
|
* |
15
|
|
|
* @property User $user |
16
|
|
|
* @property File $photoFile |
17
|
|
|
*/ |
18
|
|
|
class UserProfile extends \yii\db\ActiveRecord |
19
|
|
|
{ |
20
|
9 |
|
public function __construct($config = []) |
21
|
|
|
{ |
22
|
9 |
|
$this->attachBehavior( |
23
|
9 |
|
'fileManager', |
24
|
9 |
|
require Yii::getAlias('@app/config/behaviors/user-profile/filemanager.php') |
25
|
|
|
); |
26
|
9 |
|
parent::__construct($config); |
27
|
9 |
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @inheritdoc |
31
|
|
|
*/ |
32
|
26 |
|
public static function tableName() |
33
|
|
|
{ |
34
|
26 |
|
return '{{%user_profile}}'; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @inheritdoc |
39
|
|
|
*/ |
40
|
|
|
public function attributeLabels() |
41
|
|
|
{ |
42
|
|
|
return [ |
43
|
|
|
'user_id' => Yii::t('app', 'User'), |
44
|
|
|
'full_name' => Yii::t('app', 'Full Name'), |
45
|
|
|
'photo' => Yii::t('app', 'Photo'), |
46
|
|
|
'birth_day' => Yii::t('app', 'Birth Day'), |
47
|
|
|
]; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return \yii\db\ActiveQuery |
52
|
|
|
*/ |
53
|
|
|
public function getUser() |
54
|
|
|
{ |
55
|
|
|
return $this->hasOne(User::class, ['id' => 'user_id']); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return \yii\db\ActiveQuery |
60
|
|
|
*/ |
61
|
|
|
public function getPhotoFile() |
62
|
|
|
{ |
63
|
|
|
return $this |
64
|
|
|
->hasOne(File::class, ['id' => 'file_id']) |
65
|
|
|
->viaTable('{{%user_profile_to_file}}', ['user_id' => 'user_id']); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @inheritdoc |
70
|
|
|
* @return \query\UserProfileQuery the active query used by this AR class. |
71
|
|
|
*/ |
72
|
11 |
|
public static function find() |
73
|
|
|
{ |
74
|
11 |
|
return new \app\models\query\UserProfileQuery(get_called_class()); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|