1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* _ __ __ _____ _____ ___ ____ _____ |
5
|
|
|
* | | / // // ___//_ _// || __||_ _| |
6
|
|
|
* | |/ // /(__ ) / / / /| || | | | |
7
|
|
|
* |___//_//____/ /_/ /_/ |_||_| |_| |
8
|
|
|
* @link https://vistart.me/ |
9
|
|
|
* @copyright Copyright (c) 2016 - 2017 vistart |
10
|
|
|
* @license https://vistart.me/license/ |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace rhosocial\base\models\queries; |
14
|
|
|
|
15
|
|
|
use rhosocial\base\models\traits\MutualQueryTrait; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Description of BaseUserRelationQuery |
19
|
|
|
* |
20
|
|
|
* Note: You must specify $modelClass property, and the class must be the subclass |
21
|
|
|
* of `\rhosocial\base\models\models\BaseUserRelationModel`. |
22
|
|
|
* @version 1.0 |
23
|
|
|
* @author vistart <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
class BaseUserRelationQuery extends BaseBlameableQuery |
26
|
|
|
{ |
27
|
|
|
use MutualQueryTrait; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Specify groups. |
31
|
|
|
* This method will be skipped if not enable the group features (`$multiBlamesAttribute = false`). |
32
|
|
|
* @param string|array $groups the guid of group If string, or guid array of |
33
|
|
|
* groups if array. If you want to get ungrouped relation(s), please assign |
34
|
|
|
* empty array, or if you do not want to delimit group(s), please do not |
35
|
|
|
* access this method, or assign null. |
36
|
|
|
* @return static $this |
37
|
|
|
*/ |
38
|
2 |
|
public function groups($groups = []) |
39
|
|
|
{ |
40
|
2 |
|
if ($groups === null) { |
41
|
1 |
|
return $this; |
42
|
|
|
} |
43
|
1 |
|
$model = $this->noInitModel; |
44
|
1 |
|
if (!is_string($model->multiBlamesAttribute)) { |
|
|
|
|
45
|
|
|
return $this; |
46
|
|
|
} |
47
|
1 |
|
if (empty($groups)) { |
48
|
1 |
|
return $this->andWhere([$model->multiBlamesAttribute => '']); |
|
|
|
|
49
|
|
|
} |
50
|
1 |
|
return $this->andWhere(['or like', $model->multiBlamesAttribute, $groups]); |
|
|
|
|
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.