I am writing an application using CakePHP and I am unsure as to where I should be putting my generateMapUrl function.
function generateMapUrl($id = null) {
if ( !$id ) {
$this->Session->setFlash('Invalid Property Id');
}
$this->read(null, $id);
$url = "http://maps.google.com/maps?oi=map&q=";
$url .= $this->data['street_num'] . '+';
$url .= $this->data['street'] . '+';
$url .= $this->data['city'] . '+';
$url .= $this->data['province'] . '+';
$url .= $this->data['country'] . '+';
$url .= $this->data['postal_code'];
return $url;
}
I have the following structure:
Booking (Model & Controller) Properties (Model & Controller) Address (Model & Controller)
A Booking hasOne Property and a Property hasOne Address. I would like to be able to call generateMapUrl for any Address. I am unsure as to where to put the method though... Address controller? Address Model? (Note: I am calling this method from the Bookings controller)