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 f86abe58..58841f9a 100644 --- a/app/Model/Category.php +++ b/app/Model/Category.php @@ -118,6 +118,34 @@ class Category extends Base } /** + * Duplicate categories from a project to another one + * + * @author Antonio Rabelo + * @param integer $project_from Project Template + * @return integer $project_to Project that receives the copy + * @return boolean + */ + public function duplicate($project_from, $project_to) + { + $categories = $this->db->table(self::TABLE) + ->columns('name') + ->eq('project_id', $project_from) + ->asc('name') + ->findAll(); + + foreach ($categories as $category) { + + $category['project_id'] = $project_to; + + if (! $this->category->create($category)) { + return false; + } + } + + return true; + } + + /** * Validate category creation * * @access public |