From 7c5b900bd83b6b9bdb5656eb169381ff46f8106a Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Fri, 20 Jun 2014 15:41:05 -0300 Subject: First API implementation --- app/Model/Project.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'app/Model/Project.php') diff --git a/app/Model/Project.php b/app/Model/Project.php index e1465012..b5716a81 100644 --- a/app/Model/Project.php +++ b/app/Model/Project.php @@ -197,6 +197,18 @@ class Project extends Base return $this->db->table(self::TABLE)->eq('id', $project_id)->findOne(); } + /** + * Get a project by the name + * + * @access public + * @param string $project_name Project name + * @return array + */ + public function getByName($project_name) + { + return $this->db->table(self::TABLE)->eq('name', $project_name)->findOne(); + } + /** * Fetch project data by using the token * @@ -505,7 +517,8 @@ class Project extends Base new Validators\Integer('id', t('This value must be an integer')), new Validators\Required('name', t('The project name is required')), new Validators\MaxLength('name', t('The maximum length is %d characters', 50), 50), - new Validators\Unique('name', t('This project must be unique'), $this->db->getConnection(), self::TABLE) + new Validators\Unique('name', t('This project must be unique'), $this->db->getConnection(), self::TABLE), + new Validators\Integer('is_active', t('This value must be an integer')) )); return array( -- cgit v1.2.3