Cake\ORM\Association\BelongsToMany::find PHP Method

find() public method

If your association includes conditions, the junction table will be included in the query's contained associations.
See also: Cake\ORM\Table::find()
public find ( string | array | null $type = null, array $options = [] ) : Query
$type string | array | null the type of query to perform, if an array is passed, it will be interpreted as the `$options` parameter
$options array The options to for the find
return Cake\ORM\Query
    public function find($type = null, array $options = [])
    {
        $type = $type ?: $this->finder();
        list($type, $opts) = $this->_extractFinder($type);
        $query = $this->target()->find($type, $options + $opts)->where($this->targetConditions());
        if (!$this->junctionConditions()) {
            return $query;
        }
        $belongsTo = $this->junction()->association($this->target()->alias());
        $conditions = $belongsTo->_joinCondition(['foreignKey' => $this->targetForeignKey()]);
        $conditions += $this->junctionConditions();
        return $this->_appendJunctionJoin($query, $conditions);
    }