AddessLink WIP
This commit is contained in:
@@ -4,6 +4,7 @@ class Address extends mfBaseModel {
|
||||
protected $forcestr = ['street','company','zip','phone','fax','mobile','note'];
|
||||
private $parent;
|
||||
private $childaddresses;
|
||||
private $links;
|
||||
private $types;
|
||||
private $attributes;
|
||||
private $permissions;
|
||||
@@ -128,6 +129,19 @@ class Address extends mfBaseModel {
|
||||
return $spin;
|
||||
}
|
||||
|
||||
public function deleteLinks() {
|
||||
$links = $this->getProperty("links");
|
||||
//var_dump($links);exit;
|
||||
if(is_array($links) && count($links)) {
|
||||
foreach($links as $type => $linktypes) {
|
||||
//var_dump($type, $linktypes);exit;
|
||||
foreach($linktypes as $link) {
|
||||
//var_dump($link);exit;
|
||||
$link->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
@@ -166,6 +180,30 @@ class Address extends mfBaseModel {
|
||||
$this->childaddresses = AddressModel::search(['parent' => $this->id]);
|
||||
return $this->childaddresses;
|
||||
}
|
||||
/*
|
||||
if($name == "links_to") {
|
||||
$links = AddressLinkModel::search(['address_id' => $this->id]);
|
||||
foreach($links as $link) {
|
||||
if(!array_key_exists($link->type, $this->links_to)) {
|
||||
$this->links_to[$link->type] = [];
|
||||
}
|
||||
$this->links_to[$link->type][] = $link->linked_to;
|
||||
}
|
||||
return $this->links_to;
|
||||
}*/
|
||||
|
||||
if($name == "links") {
|
||||
$links = AddressLinkModel::search(['origin_address_id' => $this->id]);
|
||||
//var_dump($links);exit;
|
||||
foreach($links as $link) {
|
||||
if(!array_key_exists($link->type, $this->links)) {
|
||||
$this->links[$link->type] = [];
|
||||
}
|
||||
$this->links[$link->type][] = $link;
|
||||
//var_dump($this->links);exit;
|
||||
}
|
||||
return $this->links;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
|
||||
Reference in New Issue
Block a user