/**
  * Finds the Zone model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Zone the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Zone::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Function for locality auto suggestion with zone name
  */
 public function actionLocalityzonesuggest()
 {
     $request = Yii::$app->request->post();
     //var_dump($request);
     list($city, $zone) = $request['depdrop_parents'];
     if ($city == 'Loading ...') {
         $city = '';
     }
     if ($zone == 'Loading ...') {
         $zone = '';
     }
     //$model = new Locality;
     if ($city && $zone) {
         $data = Locality::find()->where(['status' => 1, 'cityId' => $city, 'zoneId' => $zone])->all();
     } else {
         $data = Locality::find()->where(['status' => 1, 'cityId' => $city])->all();
     }
     $dataLoc = array();
     foreach ($data as $value) {
         $obj = new \stdClass();
         $obj->id = $value->Id;
         $obj->zoneId = $value->zoneId;
         $zoneName = \common\models\Zone::findOne(['status' => 1, 'Id' => $obj->zoneId]);
         $obj->name = $value->name . ' (' . $zoneName->name . ')';
         $dataLoc[] = $obj;
     }
     $result = new \stdClass();
     $result->output = $dataLoc;
     $result->selected = "";
     header('Content-Type: application/json');
     echo Json::encode($result);
     \yii::$app->end();
 }