/** * Save the entry to a log * @param int $parent_id * @throws \Exception */ public function add_entry($parent_id = 0) { $logText = $_POST['logText']; settype($logText, "string"); $date = $_POST['date']; settype($date, "string"); $log_entry = new Log_entry(); $log_entry->text = $logText; $log_entry->parent_id = (int) $parent_id; $log_entry->date_added = new \DateTime($date); if ($id = $log_entry->saveToDb()) { $this->print_ajax($id); } else { $this->print_ajax("false"); } }