summaryrefslogtreecommitdiff
path: root/app/Model/Category.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-11-22 18:22:10 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-11-22 18:22:10 -0500
commit77e10d25829f3523a168bf61424fac99a539f8be (patch)
tree9b3d274146fa9543c4734a945e61b9d975960ff6 /app/Model/Category.php
parent15038cdb10f8c691edc7980fd1aed32dcbed3f9f (diff)
Improve API to return id instead of a boolean
Diffstat (limited to 'app/Model/Category.php')
-rw-r--r--app/Model/Category.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/Model/Category.php b/app/Model/Category.php
index fb54594b..913c3e35 100644
--- a/app/Model/Category.php
+++ b/app/Model/Category.php
@@ -94,11 +94,18 @@ class Category extends Base
*
* @access public
* @param array $values Form values
- * @return bool
+ * @return bool|integer
*/
public function create(array $values)
{
- return $this->db->table(self::TABLE)->save($values);
+ return $this->db->transaction(function($db) use ($values) {
+
+ if (! $db->table(Category::TABLE)->save($values)) {
+ return false;
+ }
+
+ return (int) $db->getConnection()->getLastId();
+ });
}
/**