summaryrefslogtreecommitdiff
path: root/app/Model/Comment.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Model/Comment.php')
-rw-r--r--app/Model/Comment.php23
1 files changed, 21 insertions, 2 deletions
diff --git a/app/Model/Comment.php b/app/Model/Comment.php
index b5102070..b849fc23 100644
--- a/app/Model/Comment.php
+++ b/app/Model/Comment.php
@@ -21,6 +21,14 @@ class Comment extends Base
const TABLE = 'comments';
/**
+ * Events
+ *
+ * @var string
+ */
+ const EVENT_UPDATE = 'comment.update';
+ const EVENT_CREATE = 'comment.create';
+
+ /**
* Get all comments for a given task
*
* @access public
@@ -95,7 +103,14 @@ class Comment extends Base
{
$values['date'] = time();
- return $this->db->table(self::TABLE)->save($values);
+ if ($this->db->table(self::TABLE)->save($values)) {
+
+ $values['id'] = $this->db->getConnection()->getLastId();
+ $this->event->trigger(self::EVENT_CREATE, $values);
+ return true;
+ }
+
+ return false;
}
/**
@@ -107,10 +122,14 @@ class Comment extends Base
*/
public function update(array $values)
{
- return $this->db
+ $result = $this->db
->table(self::TABLE)
->eq('id', $values['id'])
->update(array('comment' => $values['comment']));
+
+ $this->event->trigger(self::EVENT_UPDATE, $values);
+
+ return $result;
}
/**