diff options
| author | Frederic Guillot <fred@kanboard.net> | 2015-02-14 16:11:13 -0500 |
|---|---|---|
| committer | Frederic Guillot <fred@kanboard.net> | 2015-02-14 16:11:13 -0500 |
| commit | f7e4c3928aba9cb7f5222cb4af67846312bbb435 (patch) | |
| tree | 78f5854a0bdc538c977bad718a11d605a4caaca6 /app/Model/TaskFilter.php | |
| parent | 364382b1b58db8bf1bd2c8866e21c869a7a5d6d0 (diff) | |
Refactoring/simplification of the pull-request about links
Diffstat (limited to 'app/Model/TaskFilter.php')
| -rw-r--r-- | app/Model/TaskFilter.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/app/Model/TaskFilter.php b/app/Model/TaskFilter.php index b5a90154..31de2795 100644 --- a/app/Model/TaskFilter.php +++ b/app/Model/TaskFilter.php @@ -18,6 +18,24 @@ class TaskFilter extends Base return $this; } + public function excludeTasks(array $task_ids) + { + $this->query->notin('id', $task_ids); + return $this; + } + + public function filterByTitle($title) + { + $this->query->ilike('title', '%'.$title.'%'); + return $this; + } + + public function filterByProjects(array $project_ids) + { + $this->query->in('project_id', $project_ids); + return $this; + } + public function filterByProject($project_id) { if ($project_id > 0) { @@ -94,6 +112,20 @@ class TaskFilter extends Base return $this->query->findAll(); } + public function toAutoCompletion() + { + return $this->query->columns('id', 'title')->filter(function(array $results) { + + foreach ($results as &$result) { + $result['value'] = $result['title']; + $result['label'] = '#'.$result['id'].' - '.$result['title']; + } + + return $results; + + })->findAll(); + } + public function toCalendarEvents() { $events = array(); |
