无法从 belongstomany table 获取字段

cant get fields from belongstomany table

我无法从下面的主题 table 中获取任何字段来显示。我得到了正确的 Students 数据,我没有得到任何错误,但是我没有从 Subjects table 得到任何字段。不确定我做错了什么。如果我删除 where 子句,我会从主题中获取所有数据,所以问题是包含中的 where 子句。

      $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'

}
....
 $sub = $this->Students->find()
            // ->contain(['Subjects'])
              ->select(['Students.id'])
               ->where(['Students.student_inactive'=>0 
                   ])
              ->order(['Students.first_name' => 'ASC'])
              ->hydrate(true);

出于某些奇怪的原因,我需要使用匹配并调用 students_subjects table subjects_students

          $sub->matching('Subjects', function ($q) use ($subId) {

                 return $q
                   ->select(['Subjects.id','Subjects.name'])
                  ->where(['Subjects.id >' =>$subId]);
                });