Completed
Push — master ( c064eb...85769a )
by Igor
03:38
created

UserProfile::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 2
cts 2
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A UserProfile::attributeLabels() 0 9 1
1
<?php
2
3
namespace app\models;
4
5
use Yii;
6
use app\models\File;
7
8
/**
9
 * This is the model class for table "user_profile".
10
 *
11
 * @property integer $user_id
12
 * @property string $full_name
13
 * @property string $photo
14
 * @property string $birth_day
15
 */
16
class UserProfile extends \yii\db\ActiveRecord
17
{
18 10
    public function __construct($config = [])
19
    {
20 10
        $this->attachBehavior(
21 10
            'fileManager',
22 10
            require Yii::getAlias('@app/models/behaviors/user-profile/filemanager.php')
23
        );
24 10
        parent::__construct($config);
25 10
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30 28
    public static function tableName()
31
    {
32 28
        return 'user_profile';
33
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38 1
    public function attributeLabels()
39
    {
40
        return [
41 1
            'user_id' => Yii::t('app', 'User'),
42 1
            'full_name' => Yii::t('app', 'Full Name'),
43 1
            'photo' => Yii::t('app', 'Photo'),
44 1
            'birth_day' => Yii::t('app', 'Birth Day'),
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
    public function getFiles($callable = null)
57
    {
58
        return $this
59
            ->hasMany(File::class, ['id' => 'file_id'])
60
            ->viaTable('user_profiles_files', ['user_id' => 'user_id'], $callable);
61
    }
62
}
63