public function actionFetchData()
 {
     $categorys = \yii\helpers\ArrayHelper::toArray(\app\models\CategoryGoogle::find()->all());
     $location = \yii\helpers\ArrayHelper::toArray(\app\models\Region::find()->all());
     $place = \yii\helpers\ArrayHelper::toArray(\app\models\Place::find()->all());
     $placeCategory = \yii\helpers\ArrayHelper::toArray(\app\models\PlaceCategory::find()->all());
     $db = ['location' => $location, 'category' => $categorys, 'place' => $place, 'place_category' => $placeCategory];
     //        echo '<pre>';
     //        print_r($db);
     //        print_r($db);
     echo json_encode($db);
     //        echo '</pre>';
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PlaceCategory::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('place');
     $query->joinWith('categoria');
     $query->join('LEFT JOIN', 'category', '`category_google`.`parent_id`=`category`.`id_categoria`');
     $query->andFilterWhere(['id' => $this->id, 'categoria_id' => $this->categoria_id]);
     $query->andFilterWhere(['like', 'place_id', $this->place_id]);
     return $dataProvider;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPlaceCategories()
 {
     return $this->hasMany(PlaceCategory::className(), ['categoria_id' => 'id']);
 }
 public function getPlaceCategories()
 {
     return $this->hasMany(CategoryGoogle::className(), ['id', 'categoria_id'])->viaTable(PlaceCategory::className(), ['categoria_id' => 'id']);
 }
示例#5
0
 public function getCategoryGoogleStr()
 {
     $strCat = "";
     $placeCategory = PlaceCategory::findAll(['place_id' => $this->place_id]);
     foreach ($placeCategory as $mcat) {
         $strCat = $strCat . " | " . CategoryGoogle::findOne($mcat->categoria_id)->name;
     }
     return $strCat;
 }
 /**
  * Finds the PlaceCategory model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return PlaceCategory the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = PlaceCategory::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }