X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/8e6248f57f92d943a011c3219120d60ee4f2f00b..80865b30a5d6a82e86d21e272ae58977d4430a64:/app/Repos/ChapterRepo.php diff --git a/app/Repos/ChapterRepo.php b/app/Repos/ChapterRepo.php index 095596a60..6868bbf89 100644 --- a/app/Repos/ChapterRepo.php +++ b/app/Repos/ChapterRepo.php @@ -156,7 +156,16 @@ class ChapterRepo */ public function getBySearch($term, $whereTerms = [], $count = 20, $paginationAppends = []) { - $terms = explode(' ', $term); + preg_match_all('/"(.*?)"/', $term, $matches); + if (count($matches[1]) > 0) { + $terms = $matches[1]; + $term = trim(preg_replace('/"(.*?)"/', '', $term)); + } else { + $terms = []; + } + if (!empty($term)) { + $terms = array_merge($terms, explode(' ', $term)); + } $chapters = $this->restrictionService->enforceChapterRestrictions($this->chapter->fullTextSearchQuery(['name', 'description'], $terms, $whereTerms)) ->paginate($count)->appends($paginationAppends); $words = join('|', explode(' ', preg_quote(trim($term), '/')));