public function addLabels(Search $entity)
    {
        if ($entity->getLabels()->count()) {
            $this->add(function (QueryBuilder $query) use ($entity) {
                $ids = [];
                foreach ($entity->getLabels() as $label) {
                    $ids[] = (int) $label->getId();
                }
                $query
                    ->innerJoin('i.labels', 'l')
                    ->andWhere('l.id IN ('.implode(',', $ids).')');
            });
            $this->select->andHaving('COUNT(i.id) = '.$entity->getLabels()->count());
        }

        return $this;
    }
public function addLabels(Search $entity)
    {
        if ($entity->getLabels()->count()) {
            $this->add(function (QueryBuilder $query) use ($entity) {
                $ids = [];
                foreach ($entity->getLabels() as $label) {
                    $ids[] = (int) $label->getId();
                }
                $query
                    ->innerJoin('i.labels', 'l')
                    ->andWhere('l.id IN ('.implode(',', $ids).')');
            });
            $this->select->andHaving('COUNT(i.id) = '.$entity->getLabels()->count());
        }

        return $this;
    }
public function addLabels ( Search $ entity ) { if ( $ entity -> getLabels ( ) -> count ( ) ) { $ this -> add ( function ( QueryBuilder $ query ) use ( $ entity ) { $ ids = [ ] ; foreach ( $ entity -> getLabels ( ) as $ label ) { $ ids [ ] = ( int ) $ label -> getId ( ) ; } $ query -> innerJoin ( 'i.labels' , 'l' ) -> andWhere ( 'l.id IN (' . implode ( ',' , $ ids ) . ')' ) ; } ) ; $ this -> select -> andHaving ( 'COUNT(i.id) = ' . $ entity -> getLabels ( ) -> count ( ) ) ; } return $ this ; }
Add labels.

@param Search $entity

@return Builder
Add labels .