summaryrefslogtreecommitdiff
path: root/app/Model/SubTask.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Model/SubTask.php')
-rw-r--r--app/Model/SubTask.php18
1 files changed, 12 insertions, 6 deletions
diff --git a/app/Model/SubTask.php b/app/Model/SubTask.php
index 886ad1f3..6cb4ec4e 100644
--- a/app/Model/SubTask.php
+++ b/app/Model/SubTask.php
@@ -138,19 +138,25 @@ class SubTask extends Base
*
* @access public
* @param array $values Form values
- * @return bool
+ * @return bool|integer
*/
public function create(array $values)
{
$this->prepare($values);
- $result = $this->db->table(self::TABLE)->save($values);
- if ($result) {
- $values['id'] = $this->db->getConnection()->getLastId();
+ return $this->db->transaction(function($db) use ($values) {
+
+ if (! $db->table(SubTask::TABLE)->save($values)) {
+ return false;
+ }
+
+ $subtask_id = (int) $db->getConnection()->getLastId();
+ $values['id'] = $subtask_id;
+
$this->event->trigger(self::EVENT_CREATE, $values);
- }
- return $result;
+ return $subtask_id;
+ });
}
/**