1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Finance module for HiPanel |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-finance |
6
|
|
|
* @package hipanel-module-finance |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hipanel\modules\server\models\query; |
12
|
|
|
|
13
|
|
|
use hiqdev\hiart\ActiveQuery; |
14
|
|
|
use Yii; |
15
|
|
|
|
16
|
|
|
class ServerQuery extends ActiveQuery |
17
|
|
|
{ |
18
|
|
|
public function withBindings(): self |
19
|
|
|
{ |
20
|
|
|
if (Yii::$app->user->can('hub.read')) { |
|
|
|
|
21
|
|
|
$this->joinWith('bindings'); |
22
|
|
|
$this->andWhere(['with_bindings' => true]); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
return $this; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function withUses(): self |
29
|
|
|
{ |
30
|
|
|
$this->joinWith('uses'); |
31
|
|
|
$this->andWhere(['with_uses' => true]); |
32
|
|
|
|
33
|
|
|
return $this; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function withBlocking(): self |
37
|
|
|
{ |
38
|
|
|
$this->joinWith('blocking'); |
39
|
|
|
$this->andWhere(['with_blocking' => true]); |
40
|
|
|
|
41
|
|
|
return $this; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function withHardwareSettings(): self |
45
|
|
|
{ |
46
|
|
|
if (Yii::$app->user->can('part.read')) { |
47
|
|
|
$this->joinWith(['hardwareSettings']); |
48
|
|
|
$this->andWhere(['with_hardwareSettings' => 1]); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
return $this; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function withSoftwareSettings(): self |
55
|
|
|
{ |
56
|
|
|
if (Yii::$app->user->can('server.manage-settings')) { |
57
|
|
|
$this->joinWith(['softwareSettings']); |
58
|
|
|
$this->andWhere(['with_softwareSettings' => 1]); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
return $this; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function withMonitoringSettings(): self |
65
|
|
|
{ |
66
|
|
|
if (Yii::$app->user->can('server.manage-settings')) { |
67
|
|
|
$this->joinWith(['monitoringSettings']); |
68
|
|
|
$this->andWhere(['with_monitoringSettings' => 1]); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
return $this; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function withConsumptions(): self |
75
|
|
|
{ |
76
|
|
|
$this->joinWith('consumptions'); |
77
|
|
|
$this->andWhere(['with_consumptions' => true]); |
78
|
|
|
|
79
|
|
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function withHardwarePrices(): self |
83
|
|
|
{ |
84
|
|
|
$this->andWhere(['with_hardwarePrices' => true]); |
85
|
|
|
|
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.