/** * Geocode the item * Returns true if it worked, false if it didn't */ public function geocode() { if ($this->location == '') { $this->latitude = 0; $this->longitude = 0; return true; } try { $geocode = Geocoder::geocode($this->location); } catch (\Exception $e) { return false; } $this->latitude = $geocode['latitude']; $this->longitude = $geocode['longitude']; return true; }
/** * Geocode the user * Returns true if it worked, false if it didn't */ public function geocode() { if ($this->address == '') { $this->latitude = 0; $this->longitude = 0; return true; } try { $geocode = Geocoder::geocode($this->address); } catch (\Exception $e) { //$this->geocode_message = get_class($e) . ' / ' . $e->getMessage(); return false; } $this->latitude = $geocode['latitude']; $this->longitude = $geocode['longitude']; return true; }