Passed
Push — master ( ea7674...25e8da )
by Andrii
04:41
created

ConfigQuery::getAvailable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Server module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-server
6
 * @package   hipanel-module-server
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, 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 ConfigQuery extends ActiveQuery
17
{
18
    public function withPrices(): self
19
    {
20
        $this->joinWith('prices');
21
        $this->andWhere(['with_prices' => true]);
22
23
        return $this;
24
    }
25
26
    public function getAvailable(): self
27
    {
28
        $this->addAction('get-available');
29
30
        return $this;
31
    }
32
33
    public function withSellerOptions(): self
34
    {
35
        $options = Yii::$app->user->isGuest ? ['seller' => Yii::$app->params['user.seller']] : [
36
            'seller' => Yii::$app->user->identity->seller,
0 ignored issues
show
Bug introduced by
Accessing seller on the interface yii\web\IdentityInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
37
            'seller_id' => Yii::$app->user->identity->seller_id,
0 ignored issues
show
Bug introduced by
Accessing seller_id on the interface yii\web\IdentityInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
38
        ];
39
        $this->andWhere($options);
40
41
        return $this;
42
    }
43
}
44