public function actionDetailSearch($location_id) { $model = new GooglePlace(['location_id' => $location_id]); if ($model->load(Yii::$app->request->post())) { $url = "https://maps.googleapis.com/maps/api/place/details/json?placeid={$model->place_id}&key={$model->apiKey}"; $client = new \linslin\yii2\curl\Curl(); $response = \yii\helpers\ArrayHelper::toArray(json_decode($client->get($url))); if ($response['status'] == "OK") { $model->setAttributes($response['result']); $model->lat = $response['result']['geometry']['location']['lat']; $model->lng = $response['result']['geometry']['location']['lng']; return $this->render('view', ['model' => $model]); } } else { return $this->render('detail_search', ['model' => $model]); } }