@@ 199-214 (lines=16) @@ | ||
196 | * |
|
197 | * @return Builder |
|
198 | */ |
|
199 | public function addGenres(Search $entity) |
|
200 | { |
|
201 | if ($entity->getGenres()->count()) { |
|
202 | $this->add(function (QueryBuilder $query) use ($entity) { |
|
203 | $ids = []; |
|
204 | foreach ($entity->getGenres() as $genre) { |
|
205 | $ids[] = (int) $genre->getId(); |
|
206 | } |
|
207 | $query |
|
208 | ->innerJoin('i.genres', 'g') |
|
209 | ->andWhere('g.id IN ('.implode(',', $ids).')'); |
|
210 | }); |
|
211 | $this->select->andHaving('COUNT(i.id) = '.$entity->getGenres()->count()); |
|
212 | } |
|
213 | ||
214 | return $this; |
|
215 | } |
|
216 | ||
217 | /** |
|
@@ 224-239 (lines=16) @@ | ||
221 | * |
|
222 | * @return Builder |
|
223 | */ |
|
224 | public function addLabels(Search $entity) |
|
225 | { |
|
226 | if ($entity->getLabels()->count()) { |
|
227 | $this->add(function (QueryBuilder $query) use ($entity) { |
|
228 | $ids = []; |
|
229 | foreach ($entity->getLabels() as $label) { |
|
230 | $ids[] = (int) $label->getId(); |
|
231 | } |
|
232 | $query |
|
233 | ->innerJoin('i.labels', 'l') |
|
234 | ->andWhere('l.id IN ('.implode(',', $ids).')'); |
|
235 | }); |
|
236 | $this->select->andHaving('COUNT(i.id) = '.$entity->getLabels()->count()); |
|
237 | } |
|
238 | ||
239 | return $this; |
|
240 | } |
|
241 | ||
242 | /** |