public function queryForRelated($tagId, $images = true)
    {
        $query = $this->find('active')
            ->select(['id', 'title', 'preview', 'slug', 'text'])
            ->matching('Tags', function (Query $q) use ($tagId) {
                return $q->where([sprintf('%s.id', $this->Tags->getAlias()) => $tagId]);
            });

        if ($images) {
            $query->where([sprintf('%s.preview NOT IN', $this->getAlias()) => [null, []]]);
        }

        return $query;
    }
public function queryForRelated($tagId, $images = true)
    {
        $query = $this->find('active')
            ->select(['id', 'title', 'preview', 'slug', 'text'])
            ->matching('Tags', function (Query $q) use ($tagId) {
                return $q->where([sprintf('%s.id', $this->Tags->getAlias()) => $tagId]);
            });

        if ($images) {
            $query->where([sprintf('%s.preview NOT IN', $this->getAlias()) => [null, []]]);
        }

        return $query;
    }
public function queryForRelated ( $ tagId , $ images = true ) { $ query = $ this -> find ( 'active' ) -> select ( [ 'id' , 'title' , 'preview' , 'slug' , 'text' ] ) -> matching ( 'Tags' , function ( Query $ q ) use ( $ tagId ) { return $ q -> where ( [ sprintf ( '%s.id' , $ this -> Tags -> getAlias ( ) ) => $ tagId ] ) ; } ) ; if ( $ images ) { $ query -> where ( [ sprintf ( '%s.preview NOT IN' , $ this -> getAlias ( ) ) => [ null , [ ] ] ] ) ; } return $ query ; }
Gets the query for related posts from a tag ID
@param int $tagId Tag ID
@param bool $images If `true`, gets only posts with images
@return Cake\ORM\Query The query builder
@since 2.23.0
Gets the query for related posts from a tag ID