У меня выходит так что я пишу один код и у меня выходит 0 записей, хотя я знаю что там 9 записей. У меня код в виджете
class Counter extends Widget
{
private $params;
public function init()
{
parent::init();
$zakaz = Zakaz::find();
$this->view->params['scoreZakazAdmin'] = $zakaz->andWhere(['action' => 1])->count();
$this->view->params['scoreZakazShop'] = $zakaz->andWhere(['id_sotrud' => Yii::$app->user->id, 'action' => 1])->count();
$this->view->params['scoreDisain'] = $zakaz->andWhere(['status' => [Zakaz::STATUS_DISAIN, Zakaz::STATUS_SUC_DISAIN, Zakaz::STATUS_DECLINED_DISAIN], 'action' => 1])->count();
}
public function run()
{
return Nav::widget([
'options' => ['class' => 'nav nav-pills headerNav'],
'items' => [
['label' => 'Заказы <span class="badge pull-right">'.$this->view->params['scoreZakazAdmin'].'</span>', 'encode' => false, 'url' => ['zakaz/admin'], 'visible' => Yii::$app->user->can('seeAdmin')],
['label' => 'Заказы <span class="badge pull-right">'.$this->view->params['scoreZakazShop'].'</span>', 'encode' => false, 'url' => ['zakaz/shop'], 'visible' => Yii::$app->user->can('seeShop')],
['label' => 'Заказы <span class="badge pull-right">'.$this->view->params['scoreDisain'].'</span>', 'encode' => false, 'url' => ['zakaz/disain'], 'visible' => Yii::$app->user->can('disain')],
]
]);
}
}
В дебаг панеле я вижу несоответствующий запрос
SELECT COUNT(*) FROM `zakaz` WHERE (`action`=1) AND ((`id_sotrud`=3) AND (`action`=1)) AND ((`status` IN (3, 4, 9)) AND (`action`=1))
C:\OpenServer\domains\crm\frontend\components\Counter.php:37
C:\OpenServer\domains\crm\frontend\views\layouts\main.php:36
C:\OpenServer\domains\crm\frontend\controllers\ZakazController.php:625
13:21:03.242 info yii\db\Command::query SELECT COUNT(*) FROM `zakaz` WHERE (`action`=1) AND ((`id_sotrud`=3) AND (`action`=1)) AND ((`status` IN (3, 4, 9)) AND (`action`=1)) AND ((`status` IN (6, 7, 10)) AND (`action`=1))
C:\OpenServer\domains\crm\frontend\components\Counter.php:38
C:\OpenServer\domains\crm\frontend\views\layouts\main.php:36
C:\OpenServer\domains\crm\frontend\controllers\ZakazController.php:625
Хотя если удалить scoreZakazShop, То будет норма