$territorialManager = $data['territorial_manager'] ?? '';
$bushChefFlorist = $data['bush_chef_florist'] ?? '';
- $territorialManagerQuery = StoreDynamic::find()->andFilterWhere(['category' => 1, 'active' => 1]);
- $bushChefFloristQuery = StoreDynamic::find()->andFilterWhere(['category' => 2, 'active' => 1]);
+ $query = StoreDynamic::find()->andFilterWhere(['active' => 1]);
if ($territorialManager) {
- $territorialManagerQuery->andFilterWhere(['value_int' => ClusterAdmin::find()
- ->andFilterWhere(['admin_id' => $territorialManager, 'active' => 1])
- ->select('cluster_id')
- ->column()]);
+ $query->andFilterWhere([
+ 'category' => 3,
+ 'value_int' => ClusterAdmin::find()
+ ->andFilterWhere(['admin_id' => $territorialManager, 'active' => 1])
+ ->select('cluster_id')
+ ->column()
+ ]);
}
if ($bushChefFlorist) {
- $bushChefFloristQuery->andWhere(['value_int' => $bushChefFlorist]);
+ $query->andWhere(['category' => 2, 'value_int' => $bushChefFlorist]);
}
- $territorialManagerStoreIds = $territorialManagerQuery->select('store_id')->column();
- $bushChefFloristStoreIds = $bushChefFloristQuery->select('store_id')->column();
+ $territorialManagerStoreIds = $query->select('store_id')->column();
+ $bushChefFloristStoreIds = $query->select('store_id')->column();
$stores = CityStore::find()
->andFilterWhere([