<div className="btn-dwn__dropdown" style={{display: dropdownVisible ? 'block' : 'none'}}></div>
$orderProducts = OrderProduct::find()
->select(['product_id', 'count(id) as amount'])
->with('category')
->groupBy(['product_id'])
->orderBy(['amount' => SORT_DESC])
->all();
$categories = array_column($orderProducts, 'category');
public function getCategory()
{
return $this->hasOne(Category::className(), ['id' => 'category_id'])->viaTable(Product::tableName(), ['id' => 'product_id']);
}
public function getProducts()
{
return $this->hasMany(Product::className(), ['category_id' => 'id'])->andOnCondition(['is_active' => true]);
}
$categories = Category::find()
->where(['>=', 'lft', $model->lft])
->andWhere(['<=', 'rgt', $model->rgt])
->with('products', function (ActiveQuery $query) {
$query->where(['is_active' => true]);
})
->all();