Files
piratepoet/lib/Models/Model.php
marco ce730d7c3b Settings router.
Here's a simple settings router. the createOrUpdate method lives
in the model, and by default all models will return true on save
or false if save went wrong.
2015-08-19 23:55:30 +02:00

31 lines
625 B
PHP

<?php
namespace MailPoet\Models;
if (!defined('ABSPATH')) exit;
class Model extends \Sudzy\ValidModel {
function __construct() {
$customValidators = new CustomValidator();
parent::__construct($customValidators->init());
}
function save() {
$this->setTimestamp();
try {
parent::save();
return true;
} catch (\Sudzy\ValidationException $e) {
return false;
} catch (Exception $e) {
return false;
}
}
private function setTimestamp() {
if ($this->created_at === null) {
$this->created_at = date("Y-m-d H:i:s");
}
}
}