diff --git a/app/Http/Controllers/frontEnd/ExploreController.php b/app/Http/Controllers/frontEnd/ExploreController.php index edb8f2ad..b2025ece 100644 --- a/app/Http/Controllers/frontEnd/ExploreController.php +++ b/app/Http/Controllers/frontEnd/ExploreController.php @@ -20,8 +20,6 @@ use App\Model\Source_data; use App\Model\Taxonomy; use App\Model\TaxonomyType; -use Geocode; -use Geolocation; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use PDF; @@ -40,7 +38,9 @@ class ExploreController extends Controller { - + public function __construct(public Geocoder $geocoder) + { + } public function geolocation(Request $request) { $ip = $request->ip(); @@ -196,10 +196,11 @@ public function geocode(Request $request) if ($chip_address != null) { - $response = Geocode::make()->address($chip_address); + $response = $this->geocoder->getCoordinatesForAddress($chip_address); if ($response) { - $lat = $response->latitude(); - $lng = $response->longitude(); + $lat = $response['lat']; + $lng = $response['lng']; + $locations = Location::with('services', 'organization')->select(DB::raw('*, ( 3959 * acos( cos( radians(' . $lat . ') ) * cos( radians( location_latitude ) ) * cos( radians( location_longitude ) - radians(' . $lng . ') ) + sin( radians(' . $lat . ') ) * sin( radians( location_latitude ) ) ) ) AS distance')) ->having('distance', '<', 2) @@ -362,11 +363,10 @@ public function filter(Request $request) // $chip_address = 'search near by'; // $chip_service = 'search near by'; } else { - $response = Geocode::make()->address($chip_address); + $response = $this->geocoder->getCoordinatesForAddress($chip_address); if ($response) { - - $lat = $response->latitude(); - $lng = $response->longitude(); + $lat = $response['lat']; + $lng = $response['lng']; } } // $client = new \GuzzleHttp\Client(); diff --git a/config/app.php b/config/app.php index 31c1b51a..ed6cda61 100755 --- a/config/app.php +++ b/config/app.php @@ -227,7 +227,6 @@ 'URL' => Illuminate\Support\Facades\URL::class, 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, - 'Geocode' => Jcf\Geocode\Facades\Geocode::class, ], ]; diff --git a/config/geocoder.php b/config/geocoder.php index d70edc77..61433804 100644 --- a/config/geocoder.php +++ b/config/geocoder.php @@ -5,7 +5,7 @@ /* * The api key used when sending Geocoding requests to Google. */ - 'key' => env('GOOGLE_MAPS_GEOCODING_API_KEY', ''), + 'key' => env('GEOCODE_GOOGLE_APIKEY', ''), /* * The language param used to set response translations for textual data.