diff options
Diffstat (limited to 'app/Model/Category.php')
-rw-r--r-- | app/Model/Category.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/Model/Category.php b/app/Model/Category.php index 7fed50a3..65fd0c56 100644 --- a/app/Model/Category.php +++ b/app/Model/Category.php @@ -46,6 +46,34 @@ class Category extends Base } /** + * Get the category name by the id + * + * @access public + * @param integer $category_id Category id + * @return string + */ + public function getNameById($category_id) + { + return $this->db->table(self::TABLE)->eq('id', $category_id)->findOneColumn('name') ?: ''; + } + + /** + * Get a category id by the project and the name + * + * @access public + * @param integer $project_id Project id + * @param string $category_name Category name + * @return integer + */ + public function getIdByName($project_id, $category_name) + { + return (int) $this->db->table(self::TABLE) + ->eq('project_id', $project_id) + ->eq('name', $category_name) + ->findOneColumn('id'); + } + + /** * Return the list of all categories * * @access public |