countrycode.$this->areacode.$this->getLast(); } else { $number = $this->countrycode.$this->areacode.$this->getFirst(); } return $number; } public function getFirst() { if($this->number_prepend_zero) { return "0".$this->first; } return $this->first; } public function getLast() { if($this->number_prepend_zero) { return "0".$this->last; } return $this->last; } public function getBaseNumber() { $base = floor($this->first / pow(10, ceil(log10($this->last - $this->first)))); if($this->number_prepend_zero) { return "0".$base; } return $base; } public function isNumberInBlock($number) { return ($number >= $this->first && $number <= $this->last); } public function getProperty($name) { if($this->$name == null) { if($name == "files") { $this->files = VoiceblocknumberFileModel::search(["voicenumberblock_id" => $this->id]); return $this->files; } if($name == "numbers") { $this->numbers = VoicenumberModel::search(["voicenumberblock_id" => $this->id]); return $this->numbers; } if($name == "number_first") { return $this->getFullNumber(); } if($name == "number_last") { return $this->getFullNumber(true); } if($name == "base") { return $this->getBaseNumber(); } $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; } }