/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Kota::find(); $dataproviderkota = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 20]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataproviderkota; } $query->andFilterWhere(['CITY_ID' => $this->CITY_ID, 'POSTAL_CODE' => $this->POSTAL_CODE]); $query->andFilterWhere(['like', 'PROVINCE_ID', $this->PROVINCE_ID])->andFilterWhere(['like', 'PROVINCE', $this->PROVINCE])->andFilterWhere(['like', 'TYPE', $this->TYPE])->andFilterWhere(['like', 'CITY_NAME', $this->CITY_NAME]); return $dataproviderkota; }
public function getCustkota() { return $this->hasOne(Kota::className(), ['CITY_ID' => 'CITY_ID']); }
protected function findModelkota($id) { if (($model = Kota::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Depdrop Kota * @author wawan * @param string $id * @since 1.1.0 * @return mixed */ public function actionLisarea() { $out = []; if (isset($_POST['depdrop_parents'])) { $parents = $_POST['depdrop_parents']; if ($parents != null) { $id = $parents[0]; $model = Kota::find()->asArray()->where(['PROVINCE_ID' => $id])->all(); // print_r($model); // die(); //$out = self::getSubCatList($cat_id); // the getSubCatList function will query the database based on the // cat_id and return an array like below: // [ // ['id'=>'<sub-cat-id-1>', 'name'=>'<sub-cat-name1>'], // ['id'=>'<sub-cat_id_2>', 'name'=>'<sub-cat-name2>'] // ] foreach ($model as $key => $value) { $out[] = ['id' => $value['CITY_ID'], 'name' => $value['CITY_NAME']]; } echo json_encode(['output' => $out, 'selected' => '']); return; } } echo Json::encode(['output' => '', 'selected' => '']); }