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; }