]> BookStack Code Mirror - bookstack/blobdiff - app/Repos/BookRepo.php
Merge branch 'custom_role_system'
[bookstack] / app / Repos / BookRepo.php
index 4ae7cc0622a18ff5205f33eac8ab9300c4ef77c7..816db4cf072e22e73c553fb03b316f6d0eb2a8ae 100644 (file)
@@ -1,8 +1,6 @@
 <?php namespace BookStack\Repos;
 
 use Activity;
-use BookStack\Exceptions\NotFoundException;
-use BookStack\Services\RestrictionService;
 use Illuminate\Support\Str;
 use BookStack\Book;
 use Views;
@@ -243,7 +241,16 @@ class BookRepo
      */
     public function getBySearch($term, $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));
+        }
         $books = $this->restrictionService->enforceBookRestrictions($this->book->fullTextSearchQuery(['name', 'description'], $terms))
             ->paginate($count)->appends($paginationAppends);
         $words = join('|', explode(' ', preg_quote(trim($term), '/')));