Improve API to return id instead of a boolean
This commit is contained in:
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user