public function update()
{
try {
$this->model->setModificationDate(time());
$document = get_object_vars($this->model);
foreach ($document as $key => $value) {
// check if the getter exists
$getter = "get" . ucfirst($key);
if (!method_exists($this->model, $getter)) {
continue;
}
// get the value from the getter
if (in_array($key, $this->getValidTableColumns("documents")) || in_array($key, $this->validColumnsPage)) {
$value = $this->model->{$getter}();
} else {
continue;
}
if (is_bool($value)) {
$value = (int) $value;
}
if (in_array($key, $this->getValidTableColumns("documents"))) {
$dataDocument[$key] = $value;
}
if (in_array($key, $this->validColumnsPage)) {
$dataPage[$key] = $value;
}
}
$this->db->insertOrUpdate("documents", $dataDocument);
$this->db->insertOrUpdate("documents_printpage", $dataPage);
$this->updateLocks();
} catch (\Exception $e) {
throw $e;
}
}