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.
This commit is contained in:
@@ -10,9 +10,21 @@ class Model extends \Sudzy\ValidModel {
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
parent::save();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user