How to filter by conditions for associated models?
I have a belongsToMany association on Users and Contacts. I would like to find the Contacts of the given User. I would need something like $this->Contacts->find()->contain(['Users' => ['Users.id' => 1]]); The cookbook speaks about giving conditions to contain, custom finder methods and sing through association key, but I did not find out how to put these together. Use Query::matching() or Query::innerJoinWith() When querying from the Contacts table, then what you are looking for is Query::matching() or Query::innerJoinWith() , not (only) Query::contain() . See Cookbook > Database Access & ORM