69 lines
1.4 KiB
PHP
69 lines
1.4 KiB
PHP
<?php
|
|
|
|
class Network extends mfBaseModel {
|
|
private $owner;
|
|
private $pops;
|
|
private $addresstypes;
|
|
private $roles;
|
|
|
|
public function loadAddresstypes() {
|
|
if(!$this->id) {
|
|
return false;
|
|
}
|
|
|
|
//$this->loadRoles();
|
|
|
|
$types = NetworkAddressModel::search(['network_id' => $this->id]);
|
|
|
|
foreach($types as $type) {
|
|
$this->addresstypes[$type->address_id][] = $type;
|
|
}
|
|
|
|
//var_dump($this->addresstypes);exit;
|
|
}
|
|
|
|
public function getProperty($name) {
|
|
if($this->$name == null) {
|
|
|
|
if($name == "owner") {
|
|
if($this->id) {
|
|
$this->owner = new Address($this->owner_id);
|
|
return $this->owner;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
if($name == "pops") {
|
|
if($this->id) {
|
|
$pops = PopModel::search(['network_id' => $this->id]);
|
|
$this->pops = $pops;
|
|
return $this->pops;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
if($name == "addresstypes") {
|
|
if($this->id) {
|
|
$this->loadAddresstypes();
|
|
return $this->addresstypes;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
$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;
|
|
}
|
|
} |