SocialAuthServices.php 2.46 KB
Newer Older
Marcello Pivanti's avatar
Marcello Pivanti committed
1
2
3
4
5
6
7
<?php

/**
 * Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
 * OPEN 2.0
 *
 *
waltermazza's avatar
waltermazza committed
8
 * @package    arter\amos\socialauth\models
Marcello Pivanti's avatar
Marcello Pivanti committed
9
10
11
12
 * @category   CategoryName
 * @author     Elite Division S.r.l.
 */

waltermazza's avatar
waltermazza committed
13
namespace arter\amos\socialauth\models;
Marcello Pivanti's avatar
Marcello Pivanti committed
14
15


waltermazza's avatar
waltermazza committed
16
17
use arter\amos\core\record\Record;
use arter\amos\socialauth\Module;
Marcello Pivanti's avatar
Marcello Pivanti committed
18
19
20

/**
 * Class SocialAuthServices
waltermazza's avatar
waltermazza committed
21
 * @package arter\amos\socialauth\models
Marcello Pivanti's avatar
Marcello Pivanti committed
22
23
24
25
26
27
28
29
30
31
32
33
 *
 * @property integer $id
 * @property integer $social_users_id
 * @property string $service
 * @property string $access_token
 * @property integer $expires_in
 * @property string $token_type
 * @property string $refresh_token
 * @property integer $token_created
 * @property string $service_id
 *
 * @property SocialAuthUsers $socialUser
waltermazza's avatar
waltermazza committed
34
 * @property \arter\amos\core\user\User $user
Marcello Pivanti's avatar
Marcello Pivanti committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
 */
class SocialAuthServices extends Record
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'social_user_services';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['social_users_id', 'service'], 'required'],
            [[
                'service',
                'access_token',
                'token_type',
                'refresh_token',
                'service_id'
            ],
                'string'
            ],
            [['social_users_id', 'expires_in', 'token_created'], 'integer'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Module::t('amossocialauth', 'ID'),
            'social_users_id' => Module::t('amossocialauth', 'Social User Id'),
            'service' => Module::t('amossocialauth', 'Service name'),
            'access_token' => Module::t('amossocialauth', 'Service Access Token'),
            'token_type' => Module::t('amossocialauth', 'Token type'),
            'expires_in' => Module::t('amossocialauth', 'Access token expiration'),
            'refresh_token' => Module::t('amossocialauth', 'Refresh token'),
            'token_created' => Module::t('amossocialauth', 'created_at'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getSocialUser()
    {
        return $this->hasOne(SocialAuthUsers::className(), ['id' => 'social_users_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUser()
    {
waltermazza's avatar
waltermazza committed
96
        return $this->hasOne(\arter\amos\core\user\User::className(), ['id' => 'user_id'])->via('socialUser');
Marcello Pivanti's avatar
Marcello Pivanti committed
97
98
    }
}