Пример #1
0
 /**
  * @param Search $entity
  *
  * @return Builder
  */
 public function addGenres(Search $entity)
 {
     if ($entity->getGenres()->count()) {
         $this->add(function (QueryBuilder $query) use($entity) {
             $ids = [];
             foreach ($entity->getGenres() as $genre) {
                 $ids[] = (int) $genre->getId();
             }
             $query->innerJoin('i.genres', 'g')->andWhere('g.id IN (' . implode(',', $ids) . ')');
         });
         $this->select->andHaving('COUNT(i.id) = ' . $entity->getGenres()->count());
     }
     return $this;
 }