37 lines
736 B
PHP
37 lines
736 B
PHP
<?php
|
|
|
|
class Vatgroup extends mfBaseModel {
|
|
private $rates;
|
|
|
|
private function loadRates() {
|
|
foreach(VatrateModel::search(["vatgroup_id" => $this->id]) as $rate) {
|
|
$this->rates[$rate->area] = $rate;
|
|
}
|
|
return $this->rates;
|
|
}
|
|
|
|
public function getProperty($name) {
|
|
if($this->$name == null) {
|
|
|
|
if(!$this->id) {
|
|
return null;
|
|
}
|
|
|
|
if($name == "rates") {
|
|
return $this->loadRates();
|
|
}
|
|
|
|
$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;
|
|
}
|
|
} |