Hi,
I cant get any fields from the subjects table below to display. I get the correct Students data, I get no errors but I dont get any any fields from Subjects table. Not sure what I am doing wrong . If I remove the where clause I get all the data from subjects so the issue is the where clause in the contain.
$students = $this->Students->find()
->contain([ 'Subjects' => function ($q) {
return $q
->select(['id','name'])
->where(['Subjects.id >' =>60]) ;
}])
->select(['Students.id','Students.last_name','Students.first_name'])
->where(['Students.student_inactive'=>false])
->hydrate(true);
foreach($students as $key=>$item2):
debug($item2);
endforeach;
/////////output
object(App\Model\Entity\Student) {
'id' => (int) 24,
'last_name' => 'Test',
'first_name' => 'Cavr',
'subjects' => [],
'[new]' => false,
'[accessible]' => [
'*' => true
],
'[dirty]' => [],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'Students'
}
....