/** * Commit changes to this locomotive * @since Version 3.9.1 * @return \Railpage\Locos\Date */ public function commit() { $this->validate(); $data = array("loco_unit_id" => $this->Loco->id, "loco_date_id" => $this->action_id, "date" => $this->Date->getTimestamp(), "date_end" => $this->DateEnd instanceof DateTime ? $this->DateEnd->format("Y-m-d") : NULL, "timestamp" => $this->Date->format("Y-m-d"), "text" => $this->text, "meta" => json_encode($this->meta)); if (filter_var($this->id)) { $this->Redis->delete($this->mckey); $where = array("date_id = ?" => $this->id); $this->db->update("loco_unit_date", $data, $where); } else { $this->db->insert("loco_unit_date", $data); $this->id = $this->db->lastInsertId(); } if (isset($this->Loco->meta['construction_cost'])) { $this->Loco->meta['construction_cost_inflated'] = ContentUtility::convertCurrency($this->Loco->meta['construction_cost'], Utility\LocomotiveUtility::getConstructionDate($this->Loco)); $this->Loco->commit(); } return $this; }