|
@@ -26,6 +26,7 @@ if($submit) {
|
|
|
$location->city = http::value("city", "trim");
|
|
$location->city = http::value("city", "trim");
|
|
|
$location->county = http::value("county", "trim");
|
|
$location->county = http::value("county", "trim");
|
|
|
$location->postal_code = http::value("postal_code", "trim");
|
|
$location->postal_code = http::value("postal_code", "trim");
|
|
|
|
|
+ $location->country = http::value("country", "trim");
|
|
|
$location->email = http::value("email", "email");
|
|
$location->email = http::value("email", "email");
|
|
|
$location->phone = http::value("phone", "trim");
|
|
$location->phone = http::value("phone", "trim");
|
|
|
$location->opening_hours = http::value("opening_hours", "trim");
|
|
$location->opening_hours = http::value("opening_hours", "trim");
|
|
@@ -42,17 +43,17 @@ if($submit) {
|
|
|
if(empty($location->address_1)) $form_exception->addError("Location line 1 is required.");
|
|
if(empty($location->address_1)) $form_exception->addError("Location line 1 is required.");
|
|
|
if(empty($location->city)) $form_exception->addError("City is required.");
|
|
if(empty($location->city)) $form_exception->addError("City is required.");
|
|
|
if(empty($location->postal_code)) $form_exception->addError("Postal code is required.");
|
|
if(empty($location->postal_code)) $form_exception->addError("Postal code is required.");
|
|
|
|
|
+ if(empty($location->country)) $form_exception->addError("Country is required.");
|
|
|
|
|
|
|
|
// Geocode
|
|
// Geocode
|
|
|
try {
|
|
try {
|
|
|
- $results = Geolocation::geocode($location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"]));
|
|
|
|
|
|
|
+ $results = Geolocation::geocode($location->getDisplayAddress(["address_1", "address_2", "city", "postal_code", "country"]));
|
|
|
|
|
|
|
|
$result = $results[0];
|
|
$result = $results[0];
|
|
|
|
|
|
|
|
foreach($result->address_components as $component) {
|
|
foreach($result->address_components as $component) {
|
|
|
$types = $component->types;
|
|
$types = $component->types;
|
|
|
if(in_array("administrative_area_level_1", $types)) $location->state = $component->long_name;
|
|
if(in_array("administrative_area_level_1", $types)) $location->state = $component->long_name;
|
|
|
- if(in_array("country", $types)) $location->country = $component->long_name;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$location->latitude = $result->geometry->location->lat;
|
|
$location->latitude = $result->geometry->location->lat;
|