コード例 #1
0
ファイル: Main.php プロジェクト: RevHealth/hcpFindertest
 /**
  * @param $hcp_id
  * @param Request $request
  * @return \Illuminate\View\View
  */
 public function force_geocode_hcp($hcp_id, Request $request)
 {
     $hcp = HcpImport::get($hcp_id);
     $hcp_address = HcpImport::getGeocodeAddress($hcp);
     $geo = null;
     $geo_address = $request->input('address');
     if ($hcp) {
         $resp = Geocode::geocode($geo_address);
         if ($resp['status'] == 'OK') {
             $id = GeoCache::create(new GeoCache(['address' => $hcp_address, 'geocoded_address' => $geo_address, 'lat' => $resp['results'][0]['geometry']['location']['lat'], 'lng' => $resp['results'][0]['geometry']['location']['lng'], 'formatted_address' => $resp['results'][0]['formatted_address'], 'location_type' => $resp['results'][0]['geometry']['location_type'], 'partial_match' => Geocode::getPartialMatchFromResponse($resp)]));
             $geo = GeoCache::get($id);
             HcpImport::update($hcp_id, ['lat' => $geo->lat, 'lng' => $geo->lng, 'geo_cache_id' => $geo->id, 'geo_address' => $geo->address]);
             $hcp = HcpImport::get($hcp_id);
             $message = "Geolocating succeeded";
         } else {
             $message = "Geolocating failed";
         }
     } else {
         $message = "HCP ID:{$hcp_id} not found";
     }
     return view("data.geolocate", ['hcp' => $hcp, 'geo' => $geo, 'message' => $message, 'api_key' => Geocode::$google_api_key]);
 }