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; } } if($name == "sections") { if($this->id) { $this->sections = NetworksectionModel::search(['network_id' => $this->id]); return $this->sections; } 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; } }