Add a filter by user and due date + minor changes

This commit is contained in:
Frédéric Guillot
2014-04-26 20:04:39 -04:00
parent 3332949c8b
commit 6551609d1b
14 changed files with 158 additions and 57 deletions

View File

@@ -127,9 +127,10 @@ class Task extends Base
*
* @access public
* @param array $filters Filters: [ ['column' => '...', 'operator' => '...', 'value' => '...'], ... ]
* @param array $sorting Sorting: [ 'column' => 'date_creation', 'direction' => 'asc']
* @return array
*/
public function find(array $filters)
public function find(array $filters, array $sorting = array())
{
$table = $this->db
->table(self::TABLE)
@@ -155,6 +156,13 @@ class Task extends Base
$table->$filter['operator']($filter['column'], $filter['value']);
}
if (empty($sorting)) {
$table->orderBy('tasks.position', 'ASC');
}
else {
$table->orderBy($sorting['column'], $sorting['direction']);
}
return $table->findAll();
}