/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = BrandsCityMap::find()->where('status=0'); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->setSort(['defaultOrder' => ['updatedOn' => SORT_DESC]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['Id' => $this->Id, 'chainId' => $this->chainId, 'cityId' => $this->cityId, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy, 'createdOn' => $this->createdOn, 'updatedOn' => $this->updatedOn, 'status' => $this->status]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'website', $this->website])->andFilterWhere(['like', 'pricefortwo', $this->pricefortwo])->andFilterWhere(['like', 'cusinies', $this->cusinies])->andFilterWhere(['like', 'specilities', $this->specilities])->andFilterWhere(['like', 'whichType', $this->whichType])->andFilterWhere(['like', 'crowd', $this->crowd])->andFilterWhere(['like', 'entityType', $this->entityType])->andFilterWhere(['like', 'facebookUrl', $this->facebookUrl])->andFilterWhere(['like', 'serves', $this->serves])->andFilterWhere(['like', 'guid', $this->guid])->andFilterWhere(['like', 'ip', $this->ip]); return $dataProvider; }
/** * Function for locality auto suggestion */ public function actionAutosuggest() { Yii::$app->response->format = Response::FORMAT_JSON; $request = Yii::$app->request->post(); list($city) = $request['depdrop_parents']; $query = BrandsCityMap::find()->where('status=1'); if (!empty($city)) { if ($city) { $query->andFilterWhere(['cityId' => $city]); } } $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query, 'pagination' => false]); $data = []; //$data[] = ['id'=>0, 'name' => 'Select Brand']; foreach ($dataProvider->getModels() as $model) { $data[] = ['id' => $model->Id, 'name' => $model->chain->name]; } return ['output' => $data]; }
<?php // $form->field($model, 'sourceId')->textInput() ?> <?php // $form->field($model, 'chainId')->dropDownList(ArrayHelper::merge(['' => 'Select'], ArrayHelper::map(\common\models\Brands::find()->andWhere(['status' => 1])->All(), 'Id', 'name'))) ?> <?php echo $form->field($model, 'cityId')->dropDownList(ArrayHelper::merge(['' => 'Select'], ArrayHelper::map(\common\models\City::find()->andWhere(['status' => 1])->All(), 'Id', 'name'))); ?> <?php echo $form->field($model, 'chainId')->widget(DepDrop::classname(), ['options' => ['id' => Html::getInputId($model, 'chainId')], 'data' => ArrayHelper::merge(['' => 'Select'], ArrayHelper::map(\common\models\BrandsCityMap::find()->andWhere(['status' => 1, 'cityId' => $model->cityId])->All(), 'Id', 'name')), 'type' => DepDrop::TYPE_SELECT2, 'pluginOptions' => ['depends' => [Html::getInputId($model, 'cityId')], 'placeholder' => 'Select Chain', 'url' => Url::to(['/chaincitymap/brands-city-map/autosuggest'])], 'select2Options' => ['pluginEvents' => ['change' => "function(v){//debug(v);\n if(typeof v.val != 'undefined'){\n jQuery('#" . $form->id . "').FormHelper('load','" . Url::to(['/restaurant/restaurant/loadchain']) . "');\n }else{\n jQuery('#" . $form->id . "').FormHelper('unlockfields');\n }\n }"]]]); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => 255]); ?> <?php if ($model->name != '') { ?> <?php Callout::begin(['options' => ['class' => 'callout-danger', 'header' => 'Password Logic']]); ?> <p></p> <ul>