public function getCitylist() { $citys = new City(); $acitys = $citys->find()->leftJoin('t_store', 't_store.city_id=geobase_city.id')->andWhere('not t_store.addr is null')->asArray()->all(); $res = []; foreach ($acitys as $a) { $res[$a['id']] = $a['name']; } return $res; }
protected function getCitylist() { $city_list = \app\modules\city\models\City::find()->where(['enable' => 1])->orderBy('name')->asArray()->all(); return $city_list; }
/** * @return \yii\db\ActiveQuery */ public function getCity() { return $this->hasOne(City::className(), ['id' => 'city_id']); }
public function getCity() { return $this->hasOne(\app\modules\city\models\City::className(), ['id' => 'city_id']); }
public function find_list_region($params) { $query['stories'] = City::find()->leftJoin('t_store', 'geobase_city.id=t_store.city_id')->where(['region_id' => $params['id']])->andwhere('t_store.id IS NOT NULL')->asArray()->all(); $query['delivery'] = City::find()->leftJoin('t_store', 'geobase_city.id=t_store.city_id')->where(['region_id' => $params['id']])->andwhere(['geobase_city.enable' => '1'])->andwhere('t_store.id IS NULL')->asArray()->all(); return $query; }
echo $form->field($model, 'id')->textInput(); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'addr')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'tel')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'city_id')->dropDownList(ArrayHelper::map(City::find()->andWhere(['enable' => 1])->all(), 'id', 'name')); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
/** * Finds the City model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return City the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = City::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }