private function getStores() { if (!empty($city = $this->getCityId())) { $store = TStore::find()->select('id')->asArray()->where('city_id = :city_id', [':city_id' => $city])->all(); } return !empty($store) ? $store : false; }
public function getStorelist() { $stores = new TStore(); $astores = $stores->find()->asArray()->all(); $res = []; foreach ($astores as $a) { $res[$a['id']] = $a['name']; } return $res; }
private function getCityId($options) { if (!empty($options['city_id'])) { $this->cityId = $options['city_id']; unset($options['city_id']); } else { if (!empty($options['store_id'])) { $this->cityId = TStore::find()->select('city_id')->where('id = :id', [':id' => $options['store_id']])->one()->city_id; } else { if (!empty($cookie = Yii::$app->request->cookies['city'])) { $this->cityId = (int) $cookie->value; } } } return $this->cityId; }
public function searchCity() { $query = TStore::find()->groupBy('city_id'); $dataProvider = new ActiveDataProvider(['query' => $query]); return $dataProvider; }
/** * Функция определения city_id по StoreID - id магазина * @param $store_id * @return int|mixed */ public function getCityid($store_id) { $store = \app\modules\autoparts\models\TStore::find()->where(['id' => $store_id])->one(); return !empty($store) ? $store->city_id : ''; }