-
Notifications
You must be signed in to change notification settings - Fork 611
/
UserPermission_User.php
66 lines (60 loc) · 1.5 KB
/
UserPermission_User.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
<?php
/**
* @link https://craftcms.com/
* @copyright Copyright (c) Pixel & Tonic, Inc.
* @license https://craftcms.github.io/license/
*/
namespace craft\records;
use craft\db\ActiveRecord;
use craft\db\Table;
use yii\db\ActiveQueryInterface;
/**
* Class UserPermission_User record.
*
* @property int $id ID
* @property int $permissionId Permission ID
* @property int $userId User ID
* @property UserPermission $permission Permission
* @property User $user User
* @author Pixel & Tonic, Inc. <support@pixelandtonic.com>
* @since 3.0.0
*/
class UserPermission_User extends ActiveRecord
{
/**
* @inheritdoc
*/
public function rules(): array
{
return [
[['permissionId'], 'unique', 'targetAttribute' => ['permissionId', 'userId']],
];
}
/**
* @inheritdoc
* @return string
*/
public static function tableName(): string
{
return Table::USERPERMISSIONS_USERS;
}
/**
* Returns the user permission user’s permission.
*
* @return ActiveQueryInterface The relational query object.
*/
public function getPermission(): ActiveQueryInterface
{
return $this->hasOne(UserPermission::class,
['id' => 'permissionId']);
}
/**
* Returns the user permission user’s user.
*
* @return ActiveQueryInterface The relational query object.
*/
public function getUser(): ActiveQueryInterface
{
return $this->hasOne(User::class, ['id' => 'userId']);
}
}