int("customer_id"); $customer = Customer::get($customer_id); if(!$customer) { throw new RuntimeException(__("Customer not found.")); } $markers = []; $locations = $customer->getLocations(); Address::load(array_column($locations, "address_id")); foreach($locations as $location) { $address = $location->getAddress(); if($address->hasGeolocation()) { $markers[] = [ "id" => (int) $location->id, "name" => $location->name, "latLng" => [ "lat" => (float) $address->latitude, "lng" => (float) $address->longitude, ], "url" => $location->getUrl(), ]; } } echo json_encode([ "success" => true, "markers" => $markers ]); break; default: throw new RuntimeException(__("Invalid action.")); } } catch(\Exception $e) { http_response_code(400); echo json_encode([ "success" => false, "message" => $e->getMessage() ]); }