Completed
Push — master ( 07c06e...0dde73 )
by Igor
01:50
created

UserProfile::photo()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 0
cp 0
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 6
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
 * 
14
 * @property User $user
15
 * @property File $photoFile
16
 */
17
class UserProfile extends \yii\db\ActiveRecord
18
{
19
    public function __construct($config = [])
20 9
    {
21
        $this->attachBehavior(
22 9
            'fileManager',
23 9
            require Yii::getAlias('@app/config/behaviors/user-profile/filemanager.php')
24 9
        );
25
        parent::__construct($config);
26 9
    }
27 9
28
    /**
29
     * @inheritdoc
30
     */
31
    public static function tableName()
32 26
    {
33
        return '{{%user_profile}}';
34 26
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39
    public function attributeLabels()
40
    {
41
        return [
42
            'user_id' => Yii::t('app', 'User'),
43
            'full_name' => Yii::t('app', 'Your name'),
44
            'photo' => Yii::t('app', 'Photo'),
45
        ];
46
    }
47
48
    /**
49
     * @return \yii\db\ActiveQuery
50
     */
51
    public function getUser()
52
    {
53
        return $this->hasOne(User::class, ['id' => 'user_id']);
54
    }
55
56
    /**
57
     * @return \yii\db\ActiveQuery
58
     */
59
    public function getPhotoFile()
60
    {
61
        return $this
62
            ->hasOne(File::class, ['id' => 'file_id'])
63
            ->viaTable('{{%user_profile_to_file}}', ['user_id' => 'user_id']);
64
    }
65
66
    /**
67
     * @inheritdoc
68
     * @return \app\models\query\UserProfileQuery the active query used by this AR class.
69
     */
70
    public static function find()
71
    {
72 11
        return new \app\models\query\UserProfileQuery(get_called_class());
73
    }
74
}
75