]> BookStack Code Mirror - bookstack/blobdiff - app/Services/SearchService.php
Trying to make the tests green.
[bookstack] / app / Services / SearchService.php
index a3186e8f4a38ceeb32d741b6803ab4699e621f8e..3d1d45c3b77d47ab356285f0f45ffa9c58b90115 100644 (file)
@@ -50,6 +50,15 @@ class SearchService
         $this->permissionService = $permissionService;
     }
 
+    /**
+     * Set the database connection
+     * @param Connection $connection
+     */
+    public function setConnection(Connection $connection)
+    {
+        $this->db = $connection;
+    }
+
     /**
      * Search all entities in the system.
      * @param string $searchString
@@ -154,6 +163,7 @@ class SearchService
         // Handle normal search terms
         if (count($terms['search']) > 0) {
             $subQuery = $this->db->table('search_terms')->select('entity_id', 'entity_type', \DB::raw('SUM(score) as score'));
+            $subQuery->where('entity_type', '=', 'BookStack\\' . ucfirst($entityType));
             $subQuery->where(function(Builder $query) use ($terms) {
                 foreach ($terms['search'] as $inputTerm) {
                     $query->orWhere('term', 'like', $inputTerm .'%');