]> BookStack Code Mirror - bookstack/blobdiff - app/Repos/ChapterRepo.php
Merge branch 'custom_role_system'
[bookstack] / app / Repos / ChapterRepo.php
index 095596a608931f10ac1912e1e017fe403f72de96..6868bbf89eb4806caa9d8c2f8ab6cdf905076f3a 100644 (file)
@@ -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), '/')));