/** * Create a new query * * @access public * @return TaskFilter */ public function create() { $this->query = $this->db->table(Task::TABLE); $this->query->left(User::TABLE, 'ua', 'id', Task::TABLE, 'owner_id'); $this->query->left(User::TABLE, 'uc', 'id', Task::TABLE, 'creator_id'); $this->query->columns(Task::TABLE . '.*', 'ua.email AS assignee_email', 'ua.name AS assignee_name', 'ua.username AS assignee_username', 'uc.email AS creator_email', 'uc.username AS creator_username'); return $this; }
/** * Format the results to the ajax autocompletion * * @access public * @return array */ public function toAutoCompletion() { return $this->query->columns(Task::TABLE . '.id', Task::TABLE . '.title')->callback(function (array $results) { foreach ($results as &$result) { $result['value'] = $result['title']; $result['label'] = '#' . $result['id'] . ' - ' . $result['title']; } return $results; })->findAll(); }
/** * Filter by a list of project id * * @access public * @param array $project_ids * @return ActivityFilter */ public function filterByProjects(array $project_ids) { $this->query->columns(ProjectActivity::TABLE . '.*', User::TABLE . '.username AS author_username', User::TABLE . '.name AS author_name', User::TABLE . '.email')->join(User::TABLE, 'id', 'creator_id')->in(ProjectActivity::TABLE . '.project_id', $project_ids)->callback(array($this, 'reorganizeDataParameters')); return $this; }