Implement negation for tag gambit

Closes #42.
This commit is contained in:
Arseny Sysolyatin 2018-03-18 20:30:44 +01:00 committed by Franz Liedke
parent 5506b3f76f
commit 7ae7603342

View File

@ -42,15 +42,14 @@ class TagGambit extends AbstractRegexGambit
{
$slugs = explode(',', trim($matches[1], '"'));
// TODO: implement $negate
$search->getQuery()->where(function ($query) use ($slugs) {
$search->getQuery()->where(function ($query) use ($slugs, $negate) {
foreach ($slugs as $slug) {
if ($slug === 'untagged') {
$query->orWhereNotExists(function ($query) {
$query->orWhereExists(function ($query) {
$query->selectRaw('1')
->from('discussions_tags')
->whereRaw('discussions.id = discussion_id');
});
}, !$negate);
} else {
$id = $this->tags->getIdForSlug($slug);
@ -59,7 +58,7 @@ class TagGambit extends AbstractRegexGambit
->from('discussions_tags')
->whereRaw('discussions.id = discussion_id')
->where('tag_id', $id);
});
}, $negate);
}
}
});