Add filtering to groups

This commit is contained in:
Isaac Connor 2021-03-02 15:10:15 -05:00
parent 7d02c68938
commit 849d71efff
1 changed files with 25 additions and 2 deletions

View File

@ -31,8 +31,31 @@ class GroupsController extends AppController {
* @return void
*/
public function index() {
$this->Group->recursive = -1;
$groups = $this->Group->find('all');
$this->Group->recursive = 0;
if ( $this->request->params['named'] ) {
$this->FilterComponent = $this->Components->load('Filter');
$conditions = $this->FilterComponent->buildFilter($this->request->params['named']);
} else {
$conditions = array();
}
$find_array = array(
'conditions' => &$conditions,
'contain' => array('Monitor'),
'joins' => array(
array(
'table' => 'Groups_Monitors',
'type' => 'left',
'conditions' => array(
'Groups_Monitors.GroupId = Group.Id',
),
),
),
'group' => '`Group`.`Id`',
);
$groups = $this->Group->find('all', $find_array);
$this->set(array(
'groups' => $groups,
'_serialize' => array('groups')