Hi, guys I need help
here is my MajorsController in a view function
$major = $this->Majors->get($id, [ 'contain' => ['Groups', 'Groups.Teachers', 'Groups.Students'], ]); $maleStudent = $this->Majors->get($id, [ 'contain' => ['Groups' => function($m){ return $m->contain(['Students' => function($mm){ return $mm->where(['Students.gender' => 0]); }]); }] ]); $femaleStudent = $this->Majors->get($id, [ 'contain' => ['Groups' => function($f){ return $f->contain(['Students' => function($ff){ return $ff->where(['Students.gender' => 1]); }]); }] ]); $this->set(compact('major')); $this->set('maleStudent', $maleStudent); $this->set('femaleStudent', $femaleStudent);
My question is, How I can select count on my maleStudent and femaleStudent in my View?
I was doing this. but it doesn’t work