$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
return [
'total' => $total,
'count' => count($results),
- 'results' => $results->sortByDesc('score')
+ 'results' => $results->sortByDesc('score')->values()
];
}
// 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 .'%');