From f758c3e47b5420c441ac8a1585d8ff2029e385f3 Mon Sep 17 00:00:00 2001 From: d9it Date: Fri, 5 Apr 2024 12:58:53 +0530 Subject: [PATCH] update distance radius changes --- .../Controllers/backend/MapController.php | 2 ++ .../frontEnd/ExploreController.php | 6 ++-- app/Model/Map.php | 2 +- ...1448_add_distance_radius_to_maps_table.php | 32 +++++++++++++++++++ resources/views/backEnd/pages/map.blade.php | 8 +++++ .../frontEnd/services/services.blade.php | 4 +-- 6 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 database/migrations/2024_04_05_051448_add_distance_radius_to_maps_table.php diff --git a/app/Http/Controllers/backend/MapController.php b/app/Http/Controllers/backend/MapController.php index f9155da7..55a92f33 100644 --- a/app/Http/Controllers/backend/MapController.php +++ b/app/Http/Controllers/backend/MapController.php @@ -118,6 +118,7 @@ public function store(Request $request) $map->geocode_map_key = $request->geocode_map_key; $map->javascript_map_key = $request->javascript_map_key; $map->distance_unit = $request->distance_unit; + $map->distance_radius = $request->get('distance_radius', 50); $map->state = $request->state; $map->lat = $request->lat; $map->long = $request->long; @@ -179,6 +180,7 @@ public function update($id, Request $request) $map->geocode_map_key = $request->input('geocode_map_key'); $map->javascript_map_key = $request->input('javascript_map_key'); $map->distance_unit = $request->input('distance_unit'); + $map->distance_radius = $request->get('distance_radius', 50); $map->state = $request->input('state'); $map->lat = $request->input('lat'); $map->long = $request->input('long'); diff --git a/app/Http/Controllers/frontEnd/ExploreController.php b/app/Http/Controllers/frontEnd/ExploreController.php index 0a797a40..9a89e310 100644 --- a/app/Http/Controllers/frontEnd/ExploreController.php +++ b/app/Http/Controllers/frontEnd/ExploreController.php @@ -75,7 +75,7 @@ public function geolocation(Request $request) // $lng = -77.0373987; $locations = Location::with('services', 'organization', 'address')->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) + ->having('distance', '<', $this->map->distance_radius) ->orderBy('distance'); $locationids = $locations->pluck('location_recordid')->toArray(); @@ -220,7 +220,7 @@ public function geocode(Request $request) } $locations = Location::with('services', 'organization')->select(DB::raw('*, ( '.$radius.' * 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) + ->having('distance', '<', $this->map->distance_radius) ->orderBy('distance'); $location_locationids = $locations->pluck('location_recordid')->toArray(); @@ -406,7 +406,7 @@ public function filter(Request $request) ) // ->select(DB::raw('* , (((acos(sin((' . $lat . ' * pi()/180)) * sin((location_latitude*pi()/180))+cos((' . $lat . ' * pi()/180)) * cos((location_latitude*pi()/180)) * cos(((' . $lng . '- location_longitude)* pi()/180))))*180/pi())*60*1.1515*5280) AS distance')) // ->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', '<', 50) + ->having('distance', '<', $this->map->distance_radius) ->orderBy('distance'); $location_locationids = $locations->pluck('location_recordid'); diff --git a/app/Model/Map.php b/app/Model/Map.php index 39dbf921..f28047b3 100644 --- a/app/Model/Map.php +++ b/app/Model/Map.php @@ -7,6 +7,6 @@ class Map extends Model { protected $fillable = [ - 'name', 'sku', 'geocode_map_key', 'state', 'lat', 'long', 'active', 'zoom', 'zoom_profile', 'javascript_map_key', + 'name', 'sku', 'geocode_map_key', 'state', 'lat', 'long', 'active', 'zoom', 'zoom_profile', 'javascript_map_key', 'distance_radius', ]; } diff --git a/database/migrations/2024_04_05_051448_add_distance_radius_to_maps_table.php b/database/migrations/2024_04_05_051448_add_distance_radius_to_maps_table.php new file mode 100644 index 00000000..e85a45f2 --- /dev/null +++ b/database/migrations/2024_04_05_051448_add_distance_radius_to_maps_table.php @@ -0,0 +1,32 @@ +double('distance_radius')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('maps', function (Blueprint $table) { + $table->dropColumn('distance_radius'); + }); + } +}; diff --git a/resources/views/backEnd/pages/map.blade.php b/resources/views/backEnd/pages/map.blade.php index 9b6d2c46..5685a375 100644 --- a/resources/views/backEnd/pages/map.blade.php +++ b/resources/views/backEnd/pages/map.blade.php @@ -79,6 +79,14 @@ +
+ +
+ +
+