Added addresstypes to address

This commit is contained in:
Frank Schubert
2021-06-17 20:39:22 +02:00
parent ed484f6fde
commit 0033247996
6 changed files with 220 additions and 9 deletions

View File

@@ -2,6 +2,8 @@
class Address extends mfBaseModel {
protected $forcestr = ['company','zip','phone','fax','mobile','note'];
private $types;
public function getFullName() {
// Assumes "Firma1 Firma2" or "firstname lastname" as readable form
@@ -18,4 +20,34 @@ class Address extends mfBaseModel {
return $name;
}
private function loadAddresstypes() {
if(!$this->id) {
return false;
}
$this->types = AddresstypeModel::search(['address_id' => $this->id]);
}
public function getProperty($name) {
if($this->$name == null) {
if($name == "types") {
$this->loadAddresstypes();
return $this->types;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = new $classname($this->$idfield);
if($this->$name->id) {
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}