41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
|
|
class PreorderStatusflagValue extends mfBaseModel {
|
|
private $preorder;
|
|
|
|
protected function afterSave() {
|
|
if(!property_exists($this->_old_data, "value") || $this->_old_data->value != $this->data->value) {
|
|
$history = PreorderHistoryModel::create([
|
|
"preorder_id" => $this->data->preorder_id,
|
|
"key" => "preorderstatusflag-".$this->data->flag_id."-value",
|
|
"old_value" => property_exists($this->_old_data, "value") ? $this->_old_data->value : null,
|
|
"new_value" => $this->data->value
|
|
]);
|
|
|
|
$history->save();
|
|
|
|
}
|
|
$this->getProperty("preorder")->afterSave();
|
|
}
|
|
|
|
public function getProperty($name) {
|
|
if($this->$name == null) {
|
|
|
|
$classname = ucfirst($name);
|
|
$idfield = $name."_id";
|
|
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
|
|
if(!$this->$name) {
|
|
$this->$name = new $classname($this->$idfield);
|
|
}
|
|
|
|
if($this->$name->id) {
|
|
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
|
|
return $this->$name;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
return $this->$name;
|
|
}
|
|
} |