From 6dfe455fd65944316dcf50cdf04f3ca47009ccf7 Mon Sep 17 00:00:00 2001 From: Albert221 Date: Sun, 3 Jan 2016 14:26:41 +0100 Subject: [PATCH 1/2] #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); } } From 9d89d8a1278500c63cf0f8499e245812d52cc77c Mon Sep 17 00:00:00 2001 From: Albert221 Date: Sun, 3 Jan 2016 14:30:35 +0100 Subject: [PATCH 2/2] Fixed code style --- src/Core/Search/Discussion/Gambit/AuthorGambit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Search/Discussion/Gambit/AuthorGambit.php b/src/Core/Search/Discussion/Gambit/AuthorGambit.php index 62e399cd3..830f033c1 100644 --- a/src/Core/Search/Discussion/Gambit/AuthorGambit.php +++ b/src/Core/Search/Discussion/Gambit/AuthorGambit.php @@ -49,7 +49,7 @@ class AuthorGambit extends AbstractRegexGambit $usernames = explode(',', $usernames); $ids = []; - foreach($usernames as $username) { + foreach ($usernames as $username) { $ids[] = $this->users->getIdForUsername($username); }