'key', 'entity_id' => 'int', 'entity' => 'string', 'label' => 'string', 'type' => 'string', 'street' => 'string', 'complement' => 'string', 'city' => 'string', 'zip' => 'string', 'country' => 'string', 'state' => 'string' ); public function mapUrl(){ $encoded = urlencode($this->street).', '.urlencode($this->zip).' '.urlencode($this->city); return 'https://www.google.com/maps/place/'.$encoded; } //retourne l'adresse sur une seule ligne au format street, complement, zip city country public function fullName(){ if($this->id==0) return ''; $fullname = ''; if(!empty($this->street)) $fullname .= $this->street; if(!empty($this->complement)) $fullname .= ', '.$this->complement; if($fullname!='') $fullname .= ', '; if(!empty($this->zip)) $fullname .= $this->zip; if(!empty($this->city)) $fullname .= ' '.$this->city; if(!empty($this->country)) $fullname .= ' '.$this->country; return $fullname; } //remplis un composant location à partir des infos de la classe courante public function toDataAttributes($plainText = true){ $array = array(); $plain = ''; foreach (array('street','complement','city','zip','country') as $key) { $array[$key] = $this->$key; $plain = ' data-'.$key.' = "'.(empty($this->$key) ? '' : $this->$key).'"'; } return !$plainText ? $array : $plain; } } ?>