diff options
Diffstat (limited to 'app/Model/TaskFilter.php')
-rw-r--r-- | app/Model/TaskFilter.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/Model/TaskFilter.php b/app/Model/TaskFilter.php index bdfbb190..b14dad0a 100644 --- a/app/Model/TaskFilter.php +++ b/app/Model/TaskFilter.php @@ -59,6 +59,9 @@ class TaskFilter extends Base case 'T_DESCRIPTION': $this->filterByDescription($value); break; + case 'T_CATEGORY': + $this->filterByCategoryName($value); + break; } } @@ -203,6 +206,30 @@ class TaskFilter extends Base } /** + * Filter by category + * + * @access public + * @param array $values List of assignees + * @return TaskFilter + */ + public function filterByCategoryName(array $values) + { + $this->query->join(Category::TABLE, 'id', 'category_id'); + $this->query->beginOr(); + + foreach ($values as $category) { + if ($category === 'none') { + $this->query->eq(Task::TABLE.'.category_id', 0); + } + else { + $this->query->eq(Category::TABLE.'.name', $category); + } + } + + $this->query->closeOr(); + } + + /** * Filter by assignee * * @access public |