public function actionZonesuggest()
 {
     $request = Yii::$app->request->post();
     $locality = $request['depdrop_parents'][0];
     $data = \common\models\Locality::findOne(['status' => 1, 'Id' => $locality]);
     $obj = new \stdClass();
     $obj->id = $data->zoneId;
     $obj->name = $data->name;
     $dataLoc[] = $obj;
     $result = new \stdClass();
     $result->output = $dataLoc;
     $result->selected = $obj->id;
     header('Content-Type: application/json');
     echo Json::encode($result);
     \yii::$app->end();
 }
 /**
  * Finds the Locality model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Locality the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Locality::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 3
0
 public function behaviors()
 {
     return array_merge(parent::behaviors(), ['url' => ['class' => 'yii\\behaviors\\AttributeBehavior', 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => 'guid', ActiveRecord::EVENT_BEFORE_UPDATE => 'guid'], 'value' => function ($event) {
         $url = '';
         $estId = $this->Id;
         $estName = $this->urlFilter($this->name);
         $locality = Locality::findOne(['Id' => $this->localityId]);
         $estLocName = $locality->name;
         $estAdd1 = $this->address;
         $estLandmark = $this->landmark;
         if (isset($this->cuisines[0]['Id'])) {
             $cuisine = Cuisine::findOne(['Id' => $this->cuisines[0]['Id']]);
         } else {
             $cuisine = Cuisine::findOne(['Id' => $this->cuisines[0]]);
         }
         $estCuisineName = $cuisine->name;
         $estWhichTypeID = $this->entityType;
         $popLocName = '';
         if ($estLocName != '') {
             $popLocName = $this->urlFilter($estLocName);
         }
         $estCityName = $this->urlFilter($this->cityname);
         if ($popLocName == "" && $estAdd1 != "") {
             $popLocName = $this->urlFilter(stripslashes($estAdd1));
         } else {
             if ($popLocName == "" && $estAdd1 == "" && $estLandmark != "") {
                 $popLocName = $this->urlFilter(stripslashes($estLandmark));
             }
         }
         if ($popLocName == "") {
             $popLocName = "no-location";
         }
         if ($estWhichTypeID == 1) {
             if (trim($estCuisineName) != '') {
                 $popCusName = $this->urlFilter($estCuisineName) . "-";
             }
             $url = '/' . $estCityName . '/' . $popLocName . '/' . $popCusName . 'restaurant-' . $estName . '/' . $estId;
         } else {
             $url = '/' . $estCityName . '/' . $popLocName . '/bar-' . $estName . '/' . $estId;
         }
         return $url;
     }], 'chainId' => ['class' => 'yii\\behaviors\\AttributeBehavior', 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => 'chainId', ActiveRecord::EVENT_BEFORE_UPDATE => 'chainId'], 'value' => function ($event) {
         if ($this->chainId > 0) {
             return $this->chainId;
         } else {
             return 0;
         }
     }]]);
 }