From 6dfe455fd65944316dcf50cdf04f3ca47009ccf7 Mon Sep 17 00:00:00 2001 From: Albert221 Date: Sun, 3 Jan 2016 14:26:41 +0100 Subject: [PATCH] #256 Added multiple author search gambit --- src/Core/Search/Discussion/Gambit/AuthorGambit.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Core/Search/Discussion/Gambit/AuthorGambit.php b/src/Core/Search/Discussion/Gambit/AuthorGambit.php index 640e7b752..62e399cd3 100644 --- a/src/Core/Search/Discussion/Gambit/AuthorGambit.php +++ b/src/Core/Search/Discussion/Gambit/AuthorGambit.php @@ -45,10 +45,14 @@ class AuthorGambit extends AbstractRegexGambit throw new LogicException('This gambit can only be applied on a DiscussionSearch'); } - $username = trim($matches[1], '"'); + $usernames = trim($matches[1], '"'); + $usernames = explode(',', $usernames); - $id = $this->users->getIdForUsername($username); + $ids = []; + foreach($usernames as $username) { + $ids[] = $this->users->getIdForUsername($username); + } - $search->getQuery()->where('start_user_id', $negate ? '!=' : '=', $id); + $search->getQuery()->whereIn('start_user_id', $ids, 'and', $negate); } }