Код: Выделить всё
class MenuProcessing
{
public static function ret($where = []){
$ret = [];
$ret [] = "<ul>Обработка ткани";
$fabrics = new NomFabrics();
/** @var NomFabrics $attribute */
foreach ($fabrics->attributes as $key => $value){
$count = 0;
if(strpos($key, 'processing_') !== false){
$count = NomFabrics::find();
$count->andWhere([$key => 1]);
foreach ($where as $wherekey => $wherevalue){
$count->andFilterWhere([
$wherekey => $wherevalue,
]);
}
$count->count();
die("<pre>".print_r($count));
if($count > 0){
$ret [] = "<li>".
Html::a($fabrics->getAttributeLabel($key),
['/all', 'processing' => str_replace("processing_", "", $key)]
)
." ({$count})</li>";
}
}
}
$ret [] = "</ul>";
return implode('', $ret);
}
}
Код: Выделить всё
<?= \app\components\MenuProcessing::ret(['use_tulle' => 1]) ?>
в некоторых местах мне нужно его использовать с дополнительным параметром фильтра
я придумал так, в функцию передаю дополнительное условие и делаю подсчет значений,
но мне кажется count() так не работает,
потому что возвращает мне не значение 1...2... и т.д
а вовзрает такое:
Код: Выделить всё
app\models\NomFabricsQuery Object ( [sql] => [on] => [joinWith] => [select] => [selectOption] => [distinct] => [from] => Array ( [0] => m_noms__fabrics ) [groupBy] => [join] => [having] => [union] => [withQueries] => [params] => Array ( ) [queryCacheDuration] => [queryCacheDependency] => [_events:yii\base\Component:private] => Array ( ) [_eventWildcards:yii\base\Component:private] => Array ( ) [_behaviors:yii\base\Component:private] => Array ( ) [where] => Array ( [processing_print] => 1 ) [limit] => [offset] => [orderBy] => [indexBy] => [emulateExecution] => [modelClass] => app\models\NomFabrics [with] => [asArray] => [multiple] => [primaryModel] => [link] => [via] => [inverseOf] => [viaMap:yii\db\ActiveQuery:private] => )
1
Код: Выделить всё
foreach ($where as $wherekey => $wherevalue){
$count->andFilterWhere([
$wherekey => $wherevalue,
]);
}
идея хорошая... а вот реализация... явно я неправильно делаю... не понимаю...
я так думаю что мой запрос активквери с foreach $where как-то обернуть в датапровайдер может быть...
подскажите плиз