added association method to GroupsController to get Monitor Id/Name of monitors that belong to the group

pull/2928/head
Pliable Pixels 2020-05-05 16:32:54 -04:00
parent 8243dc0b19
commit 0817ea3bfb
1 changed files with 20 additions and 2 deletions

View File

@ -31,7 +31,7 @@ class GroupsController extends AppController {
* @return void
*/
public function index() {
$this->Group->recursive = -1;
$this->Group->recursive = 1;
$groups = $this->Group->find('all');
$this->set(array(
'groups' => $groups,
@ -170,5 +170,23 @@ class GroupsController extends AppController {
array('action' => 'index')
);
}
} // end function delete
} // end function delete
// returns monitor associations
public function associations() {
$this->Group->recursive = -1;
$groups = $this->Group->find('all', array(
'contain'=> array(
'Monitor' => array(
'fields'=>array('Id','Name')
)
)
)
);
$this->set(array(
'groups' => $groups,
'_serialize' => array('groups')
));
} // end associations
} // end class GroupController