1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (c) Flipbox Digital Limited |
5
|
|
|
* @license https://flipboxfactory.com/software/organization/license |
6
|
|
|
* @link https://www.flipboxfactory.com/software/organization/ |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace flipbox\organizations\db; |
10
|
|
|
|
11
|
|
|
use craft\helpers\Db; |
12
|
|
|
use flipbox\craft\sortable\associations\db\SortableAssociationQuery; |
13
|
|
|
use flipbox\organizations\records\UserTypeAssociation; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @author Flipbox Factory <[email protected]> |
17
|
|
|
* @since 1.0.0 |
18
|
|
|
* |
19
|
|
|
* @method UserTypeAssociation one($db = null) |
20
|
|
|
* @method UserTypeAssociation[] all($db = null) |
21
|
|
|
* @method UserTypeAssociation[] getCachedResult($db = null) |
22
|
|
|
*/ |
23
|
|
|
class UserTypeAssociationQuery extends SortableAssociationQuery |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var int|int[]|false|null The user Id(s). Prefix Ids with "not " to exclude them. |
27
|
|
|
*/ |
28
|
|
|
public $userId; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var int|int[]|false|null The type Id(s). Prefix Ids with "not " to exclude them. |
32
|
|
|
*/ |
33
|
|
|
public $typeId; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @inheritdoc |
37
|
|
|
*/ |
38
|
|
|
protected function fixedOrderColumn(): string |
39
|
|
|
{ |
40
|
|
|
return 'typeId'; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @inheritdoc |
45
|
|
|
* return static |
46
|
|
|
*/ |
47
|
|
|
public function type($value) |
48
|
|
|
{ |
49
|
|
|
return $this->typeId($value); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @inheritdoc |
54
|
|
|
* return static |
55
|
|
|
*/ |
56
|
|
|
public function typeId($value) |
57
|
|
|
{ |
58
|
|
|
$this->typeId = $value; |
59
|
|
|
return $this; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @inheritdoc |
64
|
|
|
* return static |
65
|
|
|
*/ |
66
|
|
|
public function user($value) |
67
|
|
|
{ |
68
|
|
|
return $this->userId($value); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @inheritdoc |
73
|
|
|
* return static |
74
|
|
|
*/ |
75
|
|
|
public function userId($value) |
76
|
|
|
{ |
77
|
|
|
$this->userId = $value; |
78
|
|
|
return $this; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @inheritdoc |
83
|
|
|
*/ |
84
|
|
|
public function prepare($builder) |
85
|
|
|
{ |
86
|
|
|
if ($this->userId !== null) { |
87
|
|
|
$this->andWhere(Db::parseParam('userId', $this->userId)); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
if ($this->typeId !== null) { |
91
|
|
|
$this->andWhere(Db::parseParam('typeId', $this->typeId)); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
return parent::prepare($builder); |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|