Profile::rules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
rs 9.4285
ccs 3
cts 3
cp 1
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
3
namespace inblank\activeuser\models;
4
5
use inblank\activeuser\traits\CommonTrait;
6
use yii;
7
use yii\db\ActiveRecord;
8
9
/**
10
 * This is the model class for table "{{%activeuser_profiles}}".
11
 * @property integer $user_id user identifier
12
 * @property string $site user web site
13
 * @property string $location user location
14
 */
15
class Profile extends ActiveRecord
16
{
17
    use CommonTrait;
18
19
    /**
20
     * @inheritdoc
21
     */
22 16
    public static function tableName()
23
    {
24 16
        return '{{%activeuser_profiles}}';
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30 9
    public function rules()
31
    {
32
        return [
33 9
            ['user_id', 'required'],
34 9
            ['user_id', 'exist', 'targetClass' => self::di('User'), 'targetAttribute' => 'id'],
35
        ];
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public function attributeLabels()
42
    {
43
        return [
44
            'user_id' => 'ID',
45
            'site' => Yii::t('activeuser_general', 'Web site'),
46
            'location' => Yii::t('activeuser_general', 'Location'),
47
        ];
48
    }
49
50
    public function getUser()
51
    {
52
        return $this->hasOne(self::di('User'), ['id' => 'user_id']);
53
    }
54
}
55