1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace roaresearch\yii2\oauth2server\models; |
4
|
|
|
|
5
|
|
|
use Yii; |
6
|
|
|
use yii\db\{ActiveQuery, ActiveRecord}; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* This is the model class for table "oauth_refresh_tokens". |
10
|
|
|
* |
11
|
|
|
* @property string $refresh_token |
12
|
|
|
* @property string $client_id |
13
|
|
|
* @property integer $user_id |
14
|
|
|
* @property string $expires |
15
|
|
|
* @property string $scope |
16
|
|
|
* |
17
|
|
|
* @property OauthClients $client |
18
|
|
|
*/ |
19
|
|
|
class OauthRefreshTokens extends ActiveRecord |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @inheritdoc |
23
|
|
|
*/ |
24
|
|
|
public static function tableName(): string |
25
|
|
|
{ |
26
|
|
|
return '{{%oauth_refresh_tokens}}'; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @inheritdoc |
31
|
|
|
*/ |
32
|
|
|
public function rules(): array |
33
|
|
|
{ |
34
|
|
|
return [ |
35
|
|
|
[['refresh_token', 'client_id', 'expires'], 'required'], |
36
|
|
|
[['user_id'], 'integer'], |
37
|
|
|
[['expires'], 'safe'], |
38
|
|
|
[['refresh_token'], 'string', 'max' => 40], |
39
|
|
|
[['client_id'], 'string', 'max' => 32], |
40
|
|
|
[['scope'], 'string', 'max' => 2000] |
41
|
|
|
]; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @inheritdoc |
46
|
|
|
*/ |
47
|
|
|
public function attributeLabels(): array |
48
|
|
|
{ |
49
|
|
|
return [ |
50
|
|
|
'refresh_token' => 'Refresh Token', |
51
|
|
|
'client_id' => 'Client ID', |
52
|
|
|
'user_id' => 'User ID', |
53
|
|
|
'expires' => 'Expires', |
54
|
|
|
'scope' => 'Scope', |
55
|
|
|
]; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return ActiveQuery |
60
|
|
|
*/ |
61
|
|
|
public function getClient(): ActiveQuery |
62
|
|
|
{ |
63
|
|
|
return $this->hasOne( |
64
|
|
|
OauthClients::class, |
65
|
|
|
['client_id' => 'client_id'] |
66
|
|
|
); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|